From: Gabriele Mohr Date: Thu, 6 Sep 2012 13:09:34 +0000 (+0200) Subject: Target::reload() added X-Git-Tag: 12.1.0~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1365bf54e31abe20869a9110a6790cc07c5977e2;p=platform%2Fupstream%2Flibzypp.git Target::reload() added Can be used in 'zypper' to reload the cache if rpm database has changed (bnc #767880) --- diff --git a/package/libzypp.changes b/package/libzypp.changes index 5a72bc64d..5392b7010 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Sep 5 11:56:54 CEST 2012 - gs@suse.de + +- Provide Target::reload() + ------------------------------------------------------------------- Sun Aug 26 01:13:31 CEST 2012 - ma@suse.de diff --git a/zypp/Target.cc b/zypp/Target.cc index c4707a8dc..0f2223682 100644 --- a/zypp/Target.cc +++ b/zypp/Target.cc @@ -79,6 +79,9 @@ namespace zypp void Target::load() { _pimpl->load(); } + void Target::reload() + { _pimpl->reload(); } + void Target::unload() { _pimpl->unload(); } diff --git a/zypp/Target.h b/zypp/Target.h index db949e149..322e9e3fb 100644 --- a/zypp/Target.h +++ b/zypp/Target.h @@ -70,6 +70,8 @@ namespace zypp */ void load(); + void reload(); + /** * unload target resolvables from the * pool diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index d0748e82f..b451f5015 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -818,7 +818,7 @@ namespace zypp filesystem::recursive_rmdir( base ); } - void TargetImpl::buildCache() + bool TargetImpl::buildCache() { Pathname base = solvfilesPath(); Pathname rpmsolv = base/"solv"; @@ -958,6 +958,12 @@ namespace zypp } } } + return build_rpm_solv; + } + + void TargetImpl::reload() + { + load( false ); } void TargetImpl::unload() @@ -967,11 +973,12 @@ namespace zypp system.eraseFromPool(); } - - void TargetImpl::load() + void TargetImpl::load( bool force ) { - buildCache(); - + bool newCache = buildCache(); + MIL << "New cache built: " << (newCache?"true":"false") << + ", force loading: " << (force?"true":"false") << endl; + // now add the repos to the pool sat::Pool satpool( sat::Pool::instance() ); Pathname rpmsolv( solvfilesPath() / "solv" ); @@ -979,10 +986,19 @@ namespace zypp // Providing an empty system repo, unload any old content Repository system( sat::Pool::instance().findSystemRepo() ); + if ( system && ! system.solvablesEmpty() ) { - system.eraseFromPool(); // invalidates system + if ( newCache || force ) + { + system.eraseFromPool(); // invalidates system + } + else + { + return; // nothing to do + } } + if ( ! system ) { system = satpool.systemRepo(); @@ -990,6 +1006,7 @@ namespace zypp try { + MIL << "adding " << rpmsolv << " to system" << endl; system.addSolv( rpmsolv ); } catch ( const Exception & exp ) diff --git a/zypp/target/TargetImpl.h b/zypp/target/TargetImpl.h index f77160739..371b8a4aa 100644 --- a/zypp/target/TargetImpl.h +++ b/zypp/target/TargetImpl.h @@ -101,13 +101,15 @@ namespace zypp Pathname _tmpSolvfilesPath; public: - void load(); + void load( bool force = true ); void unload(); + void reload(); + void clearCache(); - void buildCache(); + bool buildCache(); //@} public: