- dont create a second CacheStore in the same scope, will lock...
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 10 Aug 2007 12:17:37 +0000 (12:17 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Fri, 10 Aug 2007 12:17:37 +0000 (12:17 +0000)
  #297627

- Don't commit on internal repo clean.
  The operation will do it. Makes cleaning faster

zypp/RepoManager.cc
zypp/RepoManager.h

index 8721588..3c6aa3e 100644 (file)
@@ -99,6 +99,34 @@ namespace zypp
 
   ////////////////////////////////////////////////////////////////////////////
 
+   /**
+    * \short Internal version of clean cache
+    *
+    * Takes an extra CacheStore reference, so we avoid internally
+    * having 2 CacheStores writing to the same database.
+    */
+  static void cleanCacheInternal( cache::CacheStore &store,
+                                  const RepoInfo &info,
+                                  const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() )
+  {
+    ProgressData progress;
+    callback::SendReport<ProgressReport> report;
+    progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
+    progress.name(str::form(_("Cleaning repository '%s' cache"), info.alias().c_str()));
+
+    if ( !store.isCached(info.alias()) )
+      return;
+   
+    MIL << info.alias() << " cleaning cache..." << endl;
+    data::RecordId id = store.lookupRepository(info.alias());
+    
+    CombinedProgressData subprogrcv(progress);
+    
+    store.cleanRepository(id, subprogrcv);
+  }
+  
+  ////////////////////////////////////////////////////////////////////////////
+  
   /**
    * Reads RepoInfo's from a repo file.
    *
@@ -509,7 +537,7 @@ namespace zypp
         }
       }
       
-      cleanCache(info);
+      cleanCacheInternal( store, info);
     }
 
     MIL << info.alias() << " building cache..." << endl;
@@ -615,28 +643,14 @@ namespace zypp
 
     return repo::RepoType::NONE;
   }
-
+    
   ////////////////////////////////////////////////////////////////////////////
-
+  
   void RepoManager::cleanCache( const RepoInfo &info,
                                 const ProgressData::ReceiverFnc & progressrcv )
   {
-    ProgressData progress;
-    callback::SendReport<ProgressReport> report;
-    progress.sendTo( ProgressReportAdaptor( progressrcv, report ) );
-    progress.name(str::form(_("Cleaning repository '%s' cache"), info.alias().c_str()));
-    
     cache::CacheStore store(_pimpl->options.repoCachePath);
-    
-    if ( !store.isCached(info.alias()) )
-      return;
-   
-    MIL << info.alias() << " cleaning cache..." << endl;
-    data::RecordId id = store.lookupRepository(info.alias());
-    
-    CombinedProgressData subprogrcv(progress);
-    
-    store.cleanRepository(id, subprogrcv);
+    cleanCacheInternal( store, info, progressrcv );
     store.commit();
   }
 
@@ -922,7 +936,7 @@ namespace zypp
         CombinedProgressData subprogrcv(progress);
         
         // now delete it from cache
-        cleanCache(todelete, subprogrcv);
+        cleanCache( todelete, subprogrcv);
 
         MIL << todelete.alias() << " sucessfully deleted." << endl;
         return;
index a94b200..ab1dfcf 100644 (file)
@@ -308,6 +308,7 @@ namespace zypp
   protected:
     RepoStatus rawMetadataStatus( const RepoInfo &info );
     RepoStatus cacheStatus( const RepoInfo &info );
+
   public:
 
   private: