- touch the repo index file after checking if to refresh so that on the
authorJan Kupec <jkupec@suse.cz>
Wed, 15 Aug 2007 11:46:17 +0000 (11:46 +0000)
committerJan Kupec <jkupec@suse.cz>
Wed, 15 Aug 2007 11:46:17 +0000 (11:46 +0000)
  next check it gets the timestamp of last check (finished FATE #301991)

zypp/RepoManager.cc
zypp/RepoManager.h

index e17a726..b7ae81a 100644 (file)
@@ -244,7 +244,7 @@ namespace zypp
       static shared_ptr<Impl> _nullimpl( new Impl );
       return _nullimpl;
     }
-
+    
   private:
     friend Impl * rwcowClone<Impl>( const Impl * rhs );
     /** clone for RWCOW_pointer */
@@ -347,6 +347,42 @@ namespace zypp
     return status;
   }
 
+  void RepoManager::touchIndexFile(const RepoInfo & info)
+  {
+    Pathname rawpath = rawcache_path_for_repoinfo( _pimpl->options, info );
+
+    RepoType repokind = info.type();
+    if ( repokind.toEnum() == RepoType::NONE_e )
+      // unknown, probe the local metadata
+      repokind = probe(rawpath.asUrl());
+    // if still unknown, just return
+    if (repokind == RepoType::NONE_e)
+      return;
+
+    Pathname p;
+    switch ( repokind.toEnum() )
+    {
+      case RepoType::RPMMD_e :
+        p = Pathname(rawpath + "/repodata/repomd.xml");
+        break;
+
+      case RepoType::YAST2_e :
+        p = Pathname(rawpath + "/content");
+        break;
+
+      case RepoType::RPMPLAINDIR_e :
+        p = Pathname(rawpath + "/cookie");
+        break;
+
+      case RepoType::NONE_e :
+      default:
+        break;
+    }
+
+    // touch the file, ignore error (they are logged anyway)
+    filesystem::touch(p);
+  }
+
   bool RepoManager::checkIfToRefreshMetadata( const RepoInfo &info,
                                               const Url &url,
                                               RawMetadataRefreshPolicy policy )
@@ -430,6 +466,9 @@ namespace zypp
           refresh = true;
         }
 
+        if (!refresh)
+          touchIndexFile(info);
+
         return refresh;
       }
       else if ( repokind.toEnum() == RepoType::RPMPLAINDIR_e )
@@ -451,6 +490,9 @@ namespace zypp
           refresh = true;
         }
 
+        if (!refresh)
+          touchIndexFile(info);
+
         return refresh;
       }
       else
index e05763b..0d73c28 100644 (file)
@@ -362,6 +362,12 @@ namespace zypp
   protected:
     RepoStatus rawMetadataStatus( const RepoInfo &info );
     RepoStatus cacheStatus( const RepoInfo &info );
+    
+    /**
+     * Update timestamp of repository index file for the specified repository \a info.
+     * Used in \ref checkIfToRefreshMetadata() for repo.refresh.delay feature. 
+     */
+    void touchIndexFile(const RepoInfo & info);
 
   public: