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

James Antill james at osuosl.org
Tue Aug 9 14:03:29 UTC 2011


 yum/__init__.py |   10 ----------
 yum/yumRepo.py  |   12 ++++++++++++
 2 files changed, 12 insertions(+), 10 deletions(-)

New commits:
commit dfb9d7eb7083e656ccbf52b9115911ac5274ada8
Author: Zdeněk Pavlas <zpavlas at redhat.com>
Date:   Tue Aug 9 14:47:02 2011 +0200

    Rearrange the free space checking code, BZ 728848
    
    Early free space checking is currently implemented only for rpms
    and drpms only, and in two different places.  The repo._getFile()
    function has all relevant data, so we can implement it there.
    
    - free space check can be removed from presto.py
    - most metadata downloads fail gratefully instead of a traceback

diff --git a/yum/__init__.py b/yum/__init__.py
index ba21613..b7808bd 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2003,16 +2003,6 @@ class YumBase(depsolve.Depsolve):
                     os.unlink(local)
 
             checkfunc = (self.verifyPkg, (po, 1), {})
-            dirstat = os.statvfs(po.repo.pkgdir)
-            if (dirstat.f_bavail * dirstat.f_bsize) <= long(po.size):
-                adderror(po, _('Insufficient space in download directory %s\n'
-                        "    * free   %s\n"
-                        "    * needed %s") %
-                         (po.repo.pkgdir,
-                          format_number(dirstat.f_bavail * dirstat.f_bsize),
-                          format_number(po.size)))
-                continue
-            
             try:
                 if i == 1 and not local_size and remote_size == po.size:
                     text = os.path.basename(po.relativepath)
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index e5e9ece..7375813 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -24,6 +24,7 @@ urlparse.uses_fragment.append("media")
 import Errors
 from urlgrabber.grabber import URLGrabber
 from urlgrabber.grabber import default_grabber
+from urlgrabber.progress import format_number
 import urlgrabber.mirror
 from urlgrabber.grabber import URLGrabError
 import repoMDObject
@@ -35,6 +36,7 @@ import sqlitesack
 from yum import config
 from yum import misc
 from yum import comps
+from yum import _
 from constants import *
 import metalink
 
@@ -796,6 +798,16 @@ class YumRepository(Repository, config.RepoConf):
             except Errors.MediaError, e:
                 verbose_logger.log(logginglevels.DEBUG_2, "Error getting package from media; falling back to url %s" %(e,))
 
+        if size:
+            dirstat = os.statvfs(os.path.dirname(local))
+            avail = dirstat.f_bavail * dirstat.f_bsize
+            if avail < long(size):
+                raise Errors.RepoError, _('''\
+Insufficient space in download directory %s
+    * free   %s
+    * needed %s'''
+                ) % (os.path.dirname(local), format_number(avail), format_number(long(size)))
+
         if url and scheme != "media":
             ugopts = self._default_grabopts(cache=cache)
             ug = URLGrabber(progress_obj = self.callback,


More information about the Yum-commits mailing list