give better hint if zypper cannot download file from out of date repository. (bnc...
authorJosef Reidinger <jreidinger@suse.cz>
Tue, 8 Apr 2008 11:17:18 +0000 (11:17 +0000)
committerJosef Reidinger <jreidinger@suse.cz>
Tue, 8 Apr 2008 11:17:18 +0000 (11:17 +0000)
src/zypper-misc.cc

index fb5095c..5bca74a 100644 (file)
@@ -1820,11 +1820,37 @@ void solve_and_commit (Zypper & zypper)
           zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
           return;
         }
-        catch ( const zypp::repo::RepoException & e ) {
+        catch ( zypp::repo::RepoException & e ) {
           ZYPP_CAUGHT(e);
+          
+          RepoManager manager(zypper.globalOpts().rm_options );
+
+          bool refresh_needed = false;
+          for(RepoInfo::urls_const_iterator it = e.info().baseUrlsBegin();
+                    it != e.info().baseUrlsEnd(); ++it)
+            {
+              RepoManager::RefreshCheckStatus stat = manager.
+                            checkIfToRefreshMetadata(e.info(), *it,
+                            RepoManager::RefreshForced );
+              if ( stat == RepoManager::REFRESH_NEEDED )
+              {
+                refresh_needed = true;
+                break;
+              }
+            }
+          
+          std::string hint = _("Please see the above error message for a hint.");
+          if (refresh_needed)
+          {
+            hint = boost::str(format(
+                // translators: the first %s is 'zypper refresh' and the second
+                // is repo allias
+                _("Repository '%s' is out of date. Running '%s' might help.")) %
+                e.info().alias() % "zypper refresh" );
+          }
           zypper.out().error(e,
               _("Problem downloading the package file from the repository:"),
-              _("Please see the above error message for a hint."));
+              hint);
           zypper.setExitCode(ZYPPER_EXIT_ERR_ZYPP);
           return;
         }