[Yum-devel] [PATCH 4/6] Get rid of duplicate downloads

Zdeněk Pavlas zpavlas at redhat.com
Wed Jul 13 16:50:36 UTC 2011


Yum depsolver sometimes tries to 'install' and 'upgrade'
the same naevr in a single transaction.  Make sure it's
downloaded only once.  This avoids rechecks.

Store checksum info in hash values so the downloader
(child process) does not need to access the database.
---
 yum/__init__.py |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/yum/__init__.py b/yum/__init__.py
index 3778e27..7f382c4 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1947,6 +1947,7 @@ class YumBase(depsolve.Depsolve):
         self.plugins.run('predownload', pkglist=pkglist)
         remote_pkgs = []
         remote_size = 0
+        local2csum = {}
         for po in pkglist:
             if hasattr(po, 'pkgtype') and po.pkgtype == 'local':
                 continue
@@ -1966,8 +1967,10 @@ class YumBase(depsolve.Depsolve):
                     # way to save this, report the error and return
                     return errors
 
-            remote_pkgs.append(po)
-            remote_size += po.size
+            if not local in local2csum:
+                local2csum[local] = po.returnIdSum()
+                remote_pkgs.append(po)
+                remote_size += po.size
 
         remote_pkgs.sort(mediasort)
         #  This is kind of a hack and does nothing in non-Fedora versions,
@@ -1980,19 +1983,7 @@ class YumBase(depsolve.Depsolve):
         local_size = 0
         done_repos = set()
         for po in remote_pkgs:
-            #  Recheck if the file is there, works around a couple of weird
-            # edge cases.
-            local = po.localPkg()
             i += 1
-            if os.path.exists(local):
-                if self.verifyPkg(local, po, False):
-                    self.verbose_logger.debug(_("using local copy of %s") %(po,))
-                    remote_size -= po.size
-                    if hasattr(urlgrabber.progress, 'text_meter_total_size'):
-                        urlgrabber.progress.text_meter_total_size(remote_size,
-                                                                  local_size)
-                    continue
-
             checkfunc = (self.verifyPkg, (po, 1), {})
             dirstat = os.statvfs(po.repo.pkgdir)
             if (dirstat.f_bavail * dirstat.f_bsize) <= long(po.size):
-- 
1.7.4.4



More information about the Yum-devel mailing list