From 58425ae95cb4b307aeb95de1696bf8b59c45d748 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Wed, 14 May 2014 13:52:19 +0200 Subject: [PATCH] Add DownloadResolvableReport::infoInCache Callback to inform about already cached packages (no download needed). --- zypp/ZYppCallbacks.h | 6 ++++++ zypp/repo/PackageProvider.cc | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/zypp/ZYppCallbacks.h b/zypp/ZYppCallbacks.h index e09ceb4..7f3b73c 100644 --- a/zypp/ZYppCallbacks.h +++ b/zypp/ZYppCallbacks.h @@ -111,6 +111,12 @@ namespace zypp INVALID // the downloaded file is invalid }; + /** Hint that package is available in the local cache (no download needed). + * This will be the only trigger for an already cached package. + */ + virtual void infoInCache( Resolvable::constPtr res_r, const Pathname & localfile_r ) + {} + virtual void start( Resolvable::constPtr /*resolvable_ptr*/ , const Url &/*url*/ diff --git a/zypp/repo/PackageProvider.cc b/zypp/repo/PackageProvider.cc index 49dfe9f..c4b9a9c 100644 --- a/zypp/repo/PackageProvider.cc +++ b/zypp/repo/PackageProvider.cc @@ -208,25 +208,25 @@ namespace zypp ManagedFile PackageProvider::Impl::providePackage() const { + ScopedGuard guardReport( newReport() ); + // check for cache hit: ManagedFile ret( providePackageFromCache() ); if ( ! ret->empty() ) { MIL << "provided Package from cache " << _package << " at " << ret << endl; + report()->infoInCache( _package, ret ); return ret; // <-- cache hit } // HERE: cache misss, do download: - Url url; RepoInfo info = _package->repoInfo(); // FIXME we only support the first url for now. if ( info.baseUrlsEmpty() ) ZYPP_THROW(Exception("No url in repository.")); - else - url = * info.baseUrlsBegin(); MIL << "provide Package " << _package << endl; - ScopedGuard guardReport( newReport() ); + Url url = * info.baseUrlsBegin(); do { _retry = false; report()->start( _package, url ); -- 2.7.4