Add DownloadResolvableReport::infoInCache
authorMichael Andres <ma@suse.de>
Wed, 14 May 2014 11:52:19 +0000 (13:52 +0200)
committerMichael Andres <ma@suse.de>
Wed, 14 May 2014 11:52:19 +0000 (13:52 +0200)
Callback to inform about already cached packages (no download needed).

zypp/ZYppCallbacks.h
zypp/repo/PackageProvider.cc

index e09ceb4..7f3b73c 100644 (file)
@@ -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*/
index 49dfe9f..c4b9a9c 100644 (file)
@@ -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 );