From 7e5cf6454b1a4495e6d8c7886218233428986116 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Fri, 4 Apr 2008 16:50:42 +0000 Subject: [PATCH] reload target, backup --- zypp/Target.cc | 3 +++ zypp/Target.h | 6 ++++++ zypp/target/TargetImpl.cc | 8 ++++++++ zypp/target/TargetImpl.h | 2 ++ zypp/zypp_detail/ZYppImpl.cc | 39 +++++++++++++++++---------------------- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/zypp/Target.cc b/zypp/Target.cc index cb98e17..e317a66 100644 --- a/zypp/Target.cc +++ b/zypp/Target.cc @@ -70,6 +70,9 @@ namespace zypp void Target::load() { _pimpl->load(); } + void Target::unload() + { _pimpl->unload(); } + target::rpm::RpmDb & Target::rpmDb() { return _pimpl->rpm(); } diff --git a/zypp/Target.h b/zypp/Target.h index 20c08ea..de05694 100644 --- a/zypp/Target.h +++ b/zypp/Target.h @@ -64,6 +64,12 @@ namespace zypp */ void load(); + /** + * unload target resolvables from the + * pool + */ + void unload(); + /** \deprecated NOOP */ ZYPP_DEPRECATED void reset() {} diff --git a/zypp/target/TargetImpl.cc b/zypp/target/TargetImpl.cc index f382301..043f8ad 100644 --- a/zypp/target/TargetImpl.cc +++ b/zypp/target/TargetImpl.cc @@ -320,6 +320,14 @@ namespace zypp } } + void TargetImpl::unload() + { + sat::Pool satpool( sat::Pool::instance() ); + Repository system( satpool.systemRepo() ); + system.eraseFromPool(); + } + + void TargetImpl::load() { buildCache(); diff --git a/zypp/target/TargetImpl.h b/zypp/target/TargetImpl.h index 7eeeb25..929cf8d 100644 --- a/zypp/target/TargetImpl.h +++ b/zypp/target/TargetImpl.h @@ -70,6 +70,8 @@ namespace zypp void load(); + void unload(); + void clearCache(); void buildCache(); diff --git a/zypp/zypp_detail/ZYppImpl.cc b/zypp/zypp_detail/ZYppImpl.cc index c59dd88..f204e17 100644 --- a/zypp/zypp_detail/ZYppImpl.cc +++ b/zypp/zypp_detail/ZYppImpl.cc @@ -31,7 +31,7 @@ namespace zypp { ///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// namespace zypp_detail - { ///////////////////////////////////////////////////////////////// + { ///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// // @@ -95,14 +95,13 @@ namespace zypp { MIL << "initTarget( " << root << endl; if (_target) { - if (_target->root() == root) { - MIL << "Repeated call to initializeTarget()" << endl; - return; - } -#warning NEED SOME NEW WAY TO INDICATE NEDD OF TARGET RELOAD -#if 0 - removeInstalledResolvables( ); -#endif + if (_target->root() == root) { + MIL << "Repeated call to initializeTarget()" << endl; + return; + } + + _target->unload(); + } _target = new Target( root ); _target->buildCache(); @@ -110,11 +109,9 @@ namespace zypp void ZYppImpl::finishTarget() { -#warning NEED SOME NEW WAY TO UNLOAD THE POOL -#if 0 if (_target) - removeInstalledResolvables(); -#endif + _target->unload(); + _target = 0; } @@ -137,19 +134,17 @@ namespace zypp ZYppCommitResult res = _target->_pimpl->commit( pool(), policy_r ); if (! policy_r.dryRun() ) { - // Tag target data invalid, so they are reloaded on the next call to - // target->resolvables(). Actually the target should do this without - // foreign help. - _target->reset(); -#warning NEED SOME NEW WAY TO INDICATE NEDD OF TARGET RELOAD -#if 0 - removeInstalledResolvables(); + + DBG << "unloading " << sat::Pool::instance().systemRepoName() << " repo from pool" << endl; + + _target->unload(); + if ( policy_r.syncPoolAfterCommit() ) { // reload new status from target - addResolvables( _target->resolvables(), true ); + DBG << "reloading " << sat::Pool::instance().systemRepoName() << " repo to pool" << endl; + _target->load(); } -#endif } MIL << "Commit (" << policy_r << ") returned: " -- 2.7.4