Tell about download-only switched on (bnc #648606)
authorJán Kupec <jkupec@suse.cz>
Mon, 25 Oct 2010 10:01:28 +0000 (12:01 +0200)
committerJán Kupec <jkupec@suse.cz>
Mon, 25 Oct 2010 10:01:28 +0000 (12:01 +0200)
src/Summary.cc
src/Summary.h
src/solve-commit.cc
src/utils/misc.cc
src/utils/misc.h

index 95754f4..2fa8241 100644 (file)
@@ -44,7 +44,11 @@ bool Summary::ResPairNameCompare::operator()(
 // --------------------------------------------------------------------------
 
 Summary::Summary(const zypp::ResPool & pool, const ViewOptions options)
-  : _viewop(options), _show_repo_alias(false), _wrap_width(80), _force_no_color(false)
+  : _viewop(options)
+  , _show_repo_alias(false)
+  , _wrap_width(80)
+  , _force_no_color(false)
+  , _download_only(false)
 {
   readPool(pool);
 }
@@ -959,20 +963,25 @@ void Summary::writeDownloadAndInstalledSizeSummary(ostream & out)
   if (_todownload > 0)
     s << format(_("Overall download size: %s.")) % _todownload << " ";
 
-  // installed size change info
-  if (_inst_size_change > 0)
-    // TrasnlatorExplanation %s will be substituted by a byte count e.g. 212 K
-    s << format(_("After the operation, additional %s will be used."))
-        % _inst_size_change.asString(0,1,1);
-  else if (_inst_size_change == 0)
-    s << _("No additional space will be used or freed after the operation.");
+  if (_download_only)
+    s << _("Download only.");
   else
   {
-    // get the absolute size
-    ByteCount abs;
-    abs = (-_inst_size_change);
-    // TrasnlatorExplanation %s will be substituted by a byte count e.g. 212 K
-    s << format(_("After the operation, %s will be freed.")) % abs.asString(0,1,1);
+    // installed size change info
+    if (_inst_size_change > 0)
+      // TrasnlatorExplanation %s will be substituted by a byte count e.g. 212 K
+      s << format(_("After the operation, additional %s will be used."))
+          % _inst_size_change.asString(0,1,1);
+    else if (_inst_size_change == 0)
+      s << _("No additional space will be used or freed after the operation.");
+    else
+    {
+      // get the absolute size
+      ByteCount abs;
+      abs = (-_inst_size_change);
+      // TrasnlatorExplanation %s will be substituted by a byte count e.g. 212 K
+      s << format(_("After the operation, %s will be freed.")) % abs.asString(0,1,1);
+    }
   }
 
   mbs_write_wrapped(out, s.str(), 0, _wrap_width);
index 8e55f61..35ff4de 100644 (file)
@@ -69,6 +69,8 @@ public:
   { _show_repo_alias = value; }
   void setForceNoColor(bool value = true)
   { _force_no_color = value; }
+  void setDownloadOnly(bool value = true)
+  { _download_only = value; }
 
   void writeNewlyInstalled(std::ostream & out);
   void writeRemoved(std::ostream & out);
@@ -118,6 +120,7 @@ private:
   bool _show_repo_alias;
   mutable unsigned _wrap_width;
   bool _force_no_color;
+  bool _download_only;
 
   bool _need_reboot;
   bool _need_restart;
index 5a8553d..9dfd66d 100755 (executable)
@@ -581,6 +581,9 @@ void solve_and_commit (Zypper & zypper)
 
     summary.setShowRepoAlias(zypper.config().show_alias);
 
+    if (get_download_option(zypper, true) == DownloadOnly)
+      summary.setDownloadOnly(true);
+
     // show the summary
     if (zypper.out().type() == Out::TYPE_XML)
       summary.dumpAsXmlTo(cout);
index 90c957b..2d94d52 100644 (file)
@@ -516,7 +516,7 @@ void list_processes_using_deleted_files(Zypper & zypper)
 
 // ----------------------------------------------------------------------------
 
-DownloadMode get_download_option(Zypper & zypper)
+DownloadMode get_download_option(Zypper & zypper, bool quiet)
 {
   DownloadMode mode;
   DownloadMode zconfig = ZConfig::instance().commit_downloadMode();
@@ -557,7 +557,7 @@ DownloadMode get_download_option(Zypper & zypper)
   }
 
   // warn about the override, both were specified
-  if (!download.empty() &&
+  if (!quiet && !download.empty() &&
       (zypper.cOpts().count("download-only") ||
        zypper.cOpts().count("download-in-advance") ||
        zypper.cOpts().count("download-in-heaps") ||
@@ -567,6 +567,9 @@ DownloadMode get_download_option(Zypper & zypper)
       str::form(_("Option '%s' overrides '%s'."), "--download", "--download-*"));
   }
 
+  if (quiet)
+    return mode;
+
   MIL << "Download mode: ";
   if      (mode == DownloadInAdvance) MIL << "in-advance";
   else if (mode == DownloadInHeaps)   MIL << "in-heaps";
index fce9d27..f2274c8 100644 (file)
@@ -141,7 +141,7 @@ void list_processes_using_deleted_files(Zypper & zypper);
  * Check whether one of --download-* or --download options was given and return
  * the specified mode.
  */
-zypp::DownloadMode get_download_option(Zypper & zypper);
+zypp::DownloadMode get_download_option(Zypper & zypper, bool quiet = false);
 
 /** Check whether packagekit is running using a DBus call */
 bool packagekit_running();