Mailinglist Archive: zypp-commit (233 mails)

< Previous Next >
[zypp-commit] <libzypp> master : Do not report cached packages as being downloaded. (bnc #545295)
  • From: Michael Andres <ma@xxxxxxx>
  • Date: Thu, 12 Nov 2009 12:12:26 +0100
  • Message-id: <E1N8Xtl-0000s6-Oa@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit e09544018451fdc0eb29853b0bc7c8e42322f7dc
Author: Michael Andres <ma@xxxxxxx>
Date: Thu Nov 12 12:12:26 2009 +0100

Do not report cached packages as being downloaded. (bnc #545295)
---
zypp/repo/PackageProvider.cc | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/zypp/repo/PackageProvider.cc b/zypp/repo/PackageProvider.cc
index 551bfef..6b3f02a 100644
--- a/zypp/repo/PackageProvider.cc
+++ b/zypp/repo/PackageProvider.cc
@@ -91,6 +91,31 @@ namespace zypp
else
url = * info.baseUrlsBegin();

+ { // check for cache hit:
+ OnMediaLocation loc( _package->location() );
+ PathInfo cachepath( info.packagesPath() / loc.filename() );
+
+ if ( cachepath.isFile() && ! loc.checksum().empty() ) // accept cache
hit with matching checksum only!
+ // Tempting to do a quick check for matching .rpm-filesize before
computing checksum,
+ // but real life shows that loc.downloadSize() and the
.rpm-filesize frequently do not
+ // match, even if loc.checksum() and the .rpm-files checksum do.
Blame the metadata generator(s).
+ {
+ CheckSum cachechecksum( loc.checksum().type(), filesystem::checksum(
cachepath.path(), loc.checksum().type() ) );
+ USR << cachechecksum << endl;
+ if ( cachechecksum == loc.checksum() )
+ {
+ ManagedFile ret( cachepath.path() );
+ if ( ! info.keepPackages() )
+ {
+ ret.setDispose( filesystem::unlink );
+ }
+ MIL << "provided Package from cache " << _package << " at " << ret
<< endl;
+ return ret; // <-- cache hit
+ }
+ }
+ }
+
+ // HERE: cache misss, do download:
MIL << "provide Package " << _package << endl;
ScopedGuard guardReport( newReport() );
ManagedFile ret;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages