[yum-commits] Branch 'yum-3_2_X' - yum/__init__.py

James Antill james at osuosl.org
Mon Oct 27 04:14:59 UTC 2008


 yum/__init__.py |   17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

New commits:
commit cfe3b8342976ba05e140d776ba67660c893cabd5
Author: James Antill <james at and.org>
Date:   Mon Oct 27 00:09:58 2008 -0400

    Check if the package has appeared before we try and download it, bug 468401

diff --git a/yum/__init__.py b/yum/__init__.py
index d679fca..3806a5c 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1124,6 +1124,21 @@ class YumBase(depsolve.Depsolve):
         i = 0
         local_size = 0
         for po in remote_pkgs:
+            #  Recheck if the file is there, works around a couple of weird
+            # edge cases.
+            local = po.localPkg()
+            if os.path.exists(local):
+                if self.verifyPkg(local, po, False):
+                    self.verbose_logger.debug(_("using local copy of %s") %(po,))
+                    i -= 1
+                    remote_size -= po.size
+                    if hasattr(urlgrabber.progress, 'text_meter_total_size'):
+                        urlgrabber.progress.text_meter_total_size(remote_size,
+                                                                  local_size)
+                    continue
+                if os.path.getsize(local) >= po.size:
+                    os.unlink(local)
+
             i += 1
             checkfunc = (self.verifyPkg, (po, 1), {})
             dirstat = os.statvfs(po.repo.pkgdir)
@@ -1137,7 +1152,7 @@ class YumBase(depsolve.Depsolve):
                 continue
             
             try:
-                if len(remote_pkgs) == 1:
+                if i == 1 and not local_size and remote_size == po.size:
                     text = os.path.basename(po.relativepath)
                 else:
                     text = '(%s/%s): %s' % (i, len(remote_pkgs),


More information about the Yum-commits mailing list