- don't check if to refresh cd/dvd repos even on user request unless forced
authorJan Kupec <jkupec@suse.cz>
Sat, 6 Oct 2007 10:16:31 +0000 (10:16 +0000)
committerJan Kupec <jkupec@suse.cz>
Sat, 6 Oct 2007 10:16:31 +0000 (10:16 +0000)
src/zypper-sources.cc
src/zypper-utils.cc

index c05171c..6a6fb47 100644 (file)
@@ -560,19 +560,32 @@ int refresh_repos(vector<string> & arguments)
       continue;
     }
 
+
     // do the refresh
+    
+    // raw metadata refresh
     bool error = false;
     if (!copts.count("build-only"))
     {
       bool force_download =
         copts.count("force") || copts.count("force-download");
 
+      // without this a cd is required to be present in the drive on each refresh
+      // (or more 'refresh needed' check)
+      bool is_cd = is_changeable_media(*repo.baseUrlsBegin());
+      if (!force_download && is_cd)
+      {
+        MIL << "Skipping refresh of a changeable read-only media." << endl;
+        continue;
+      }
+
       MIL << "calling refreshMetadata" << (force_download ? ", forced" : "")
           << endl;
 
       error = refresh_raw_metadata(repo, force_download);
     }
 
+    // db rebuild
     if (!(error || copts.count("download-only")))
     {
       bool force_build =
@@ -657,7 +670,6 @@ std::string timestamp ()
 
 // ----------------------------------------------------------------------------
 
-//! \todo handle zypp exceptions
 static
 int add_repo(RepoInfo & repo)
 {
index e1cbe2d..d90ebb6 100644 (file)
@@ -52,6 +52,7 @@ ostream& report_a_bug (ostream& stm)
 
 bool is_changeable_media(const zypp::Url & url)
 {
+  MIL << "Checking if this is a changeable medium" << endl;
   bool is_cd = false;
   try
   {
@@ -63,7 +64,7 @@ bool is_changeable_media(const zypp::Url & url)
   catch (const media::MediaException & e)
   {
     ZYPP_CAUGHT(e);
-    WAR << "Could not determine if the URL points to a changeable media" << endl;
+    WAR << "Could not determine if the URL points to a changeable medium" << endl;
   }
 
   return is_cd;