From 11cc30de1f082e67aee9880d64e5b6b36d14bfca Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Fri, 10 Aug 2007 12:17:37 +0000 Subject: [PATCH] - dont create a second CacheStore in the same scope, will lock... #297627 - Don't commit on internal repo clean. The operation will do it. Makes cleaning faster --- zypp/RepoManager.cc | 52 +++++++++++++++++++++++++++++++++------------------- zypp/RepoManager.h | 1 + 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc index 8721588..3c6aa3e 100644 --- a/zypp/RepoManager.cc +++ b/zypp/RepoManager.cc @@ -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 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 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; diff --git a/zypp/RepoManager.h b/zypp/RepoManager.h index a94b200..ab1dfcf 100644 --- a/zypp/RepoManager.h +++ b/zypp/RepoManager.h @@ -308,6 +308,7 @@ namespace zypp protected: RepoStatus rawMetadataStatus( const RepoInfo &info ); RepoStatus cacheStatus( const RepoInfo &info ); + public: private: -- 2.7.4