return more information from checking if metadata need refresh, so user can get bette...
authorJosef Reidinger <jreidinger@suse.cz>
Thu, 20 Mar 2008 13:57:20 +0000 (13:57 +0000)
committerJosef Reidinger <jreidinger@suse.cz>
Thu, 20 Mar 2008 13:57:20 +0000 (13:57 +0000)
VERSION.cmake
zypp/RepoManager.cc
zypp/RepoManager.h

index 3acc634..2f56ffe 100644 (file)
@@ -45,6 +45,6 @@
 #
 
 SET(LIBZYPP_MAJOR "4")
-SET(LIBZYPP_MINOR "5")
-SET(LIBZYPP_COMPATMINOR "5")
+SET(LIBZYPP_MINOR "6")
+SET(LIBZYPP_COMPATMINOR "6")
 SET(LIBZYPP_PATCH "0")
index 258dfe2..423fbe1 100644 (file)
@@ -386,7 +386,8 @@ namespace zypp
     filesystem::touch(p);
   }
 
-  bool RepoManager::checkIfToRefreshMetadata( const RepoInfo &info,
+  RepoManager::RefreshCheckStatus RepoManager::checkIfToRefreshMetadata(
+                                              const RepoInfo &info,
                                               const Url &url,
                                               RawMetadataRefreshPolicy policy )
   {
@@ -434,7 +435,7 @@ namespace zypp
               << "' has been refreshed less than repo.refresh.delay ("
               << ZConfig::instance().repo_refresh_delay()
               << ") minutes ago. Advising to skip refresh" << endl;
-          return false;
+          return REPO_DELAYED;
         }
       }
 
@@ -472,7 +473,7 @@ namespace zypp
         if (!refresh)
           touchIndexFile(info);
 
-        return refresh;
+        return refresh ? REFRESH_NEEDED : REPO_UP_TO_DATE;
       }
 #if 0
       else if ( repokind.toEnum() == RepoType::RPMPLAINDIR_e )
@@ -512,7 +513,7 @@ namespace zypp
       ZYPP_RETHROW(e);
     }
 
-    return true; // default
+    return REFRESH_NEEDED; // default
   }
 
   void RepoManager::refreshMetadata( const RepoInfo &info,
@@ -534,7 +535,7 @@ namespace zypp
 
         // check whether to refresh metadata
         // if the check fails for this url, it throws, so another url will be checked
-        if (!checkIfToRefreshMetadata(info, url, policy))
+        if (checkIfToRefreshMetadata(info, url, policy)!=REFRESH_NEEDED)
           return;
 
         MIL << "Going to refresh metadata from " << url << endl;
index 4d5f3af..caff680 100644 (file)
@@ -106,6 +106,15 @@ namespace zypp
     RepoStatus metadataStatus( const RepoInfo &info ) const;
 
     /**
+     * Possibly return state of checkIfRefreshMEtadata function
+     */
+    enum RefreshCheckStatus {
+      REFRESH_NEEDED,  /**< refresh is needed */
+      REPO_UP_TO_DATE, /**< repository not changed */
+      REPO_DELAYED     /**< refresh is delayed due to settings */
+    };
+
+    /**
      * Checks whether to refresh metadata for specified repository and url.
      * <p>
      * The need for refresh is evaluated according to the following conditions,
@@ -133,7 +142,7 @@ namespace zypp
      *   {
      *     // check whether to refresh metadata
      *     // if the check fails for this url, it throws, so another url will be checked
-     *     if (!checkIfToRefreshMetadata(info, *it, policy))
+     *     if (checkIfToRefreshMetadata(info, *it, policy)!=RepoInfo::REFRESH_NEEDED)
      *       return;
      *
      *     // do the actual refresh
@@ -152,12 +161,14 @@ namespace zypp
      * \param info
      * \param url
      * \param policy
+     * \return state of repository 
+     * \see RefreshCheckStatus
      * \throws RepoUnknownTypeException
      * \throws repo::RepoNoAliasException if can't figure an alias
      * \throws Exception on unknown error
      *
      */
-    bool checkIfToRefreshMetadata( const RepoInfo &info,
+    RefreshCheckStatus checkIfToRefreshMetadata( const RepoInfo &info,
                                    const Url &url,
                                    RawMetadataRefreshPolicy policy = RefreshIfNeeded);