[yum-commits] yum/misc.py yum/yumRepo.py

zpavlas at osuosl.org zpavlas at osuosl.org
Thu Jul 18 13:29:41 UTC 2013


 yum/misc.py    |   11 ++++++-----
 yum/yumRepo.py |   31 +++++++++----------------------
 2 files changed, 15 insertions(+), 27 deletions(-)

New commits:
commit d140ae8453ab54774343b31024d7d44c6726a0ba
Author: Zdenek Pavlas <zpavlas at redhat.com>
Date:   Thu Jul 18 11:35:01 2013 +0200

    Preload from root cache when --cacheonly. BZ 830523, 903631
    
    - repo_gen_decompress(): always attempt to decompress if timestamps
      don't match.  When we can't and --cacheonly, return None (compat).
    
    - _dirSetupMkdir_p(): mkdir when --cacheonly.  We raise RepoError
      on failure (same exception, just different msg).
    
    - _retrieveMD(): preload and check the existing file first. If it does
      not match and --cacheonly, raise RepoError.
    
    This works well in casual use (I unlink my user cachedir often to trigger
    preloading), but I wouldn't be too shocked if this breaks something..
    The only way to test this to try it out.

diff --git a/yum/misc.py b/yum/misc.py
index bb84815..aae13c2 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -1158,12 +1158,13 @@ def repo_gen_decompress(filename, generated_name, cached=False):
         generated name, and use check_timestamps. filename _must_ be from
         a repo. and generated_name is the type of the file. """
     dest = os.path.dirname(filename) + '/gen/' + generated_name
-    ret = decompress(filename, dest=dest, check_timestamps=True,fn_only=cached)
+    try:
+        return decompress(filename, dest=dest, check_timestamps=True)
+    except IOError, e:
+        if cached and e.errno == errno.EACCES:
+            return None
+        raise
 
-    if cached and ret and not os.path.exists(ret):
-        return None
-    return ret
-    
 def read_in_items_from_dot_dir(thisglob, line_as_list=True):
     """takes a glob of a dir (like /etc/foo.d/*.foo)
        returns a list of all the lines in all the files matching
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 3a85578..53c0ab2 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -697,9 +697,6 @@ class YumRepository(Repository, config.RepoConf):
         if os.path.exists(dpath) and os.path.isdir(dpath):
             return
 
-        if self.cache:
-            raise Errors.RepoError, "Cannot access repository dir %s" % dpath
-
         try:
             os.makedirs(dpath, mode=0755)
         except OSError, e:
@@ -1802,31 +1799,21 @@ Insufficient space in download directory %s
             # got it, move along
             return local
 
-        if self.cache == 1:
-            if os.path.exists(local):
-                try:
-                    self.checkMD(local, mdtype)
-                except URLGrabError, e:
-                    if retrieve_can_fail:
-                        return None
-                    raise Errors.RepoError, \
-                        "Caching enabled and local cache: %s does not match checksum" % local
-                else:
-                    return local
-
-            else: # ain't there - raise
-                if retrieve_can_fail:
-                    return None
-                raise Errors.RepoError, \
-                    "Caching enabled but no local cache of %s from %s" % (local,
-                           self.ui_id)
-
         if (os.path.exists(local) or
             self._preload_md_from_system_cache(os.path.basename(local))):
             if self._checkMD(local, mdtype, check_can_fail=True):
                 self.retrieved[mdtype] = 1
                 return local # it's the same return the local one
 
+        if self.cache == 1:
+            if retrieve_can_fail:
+                return None
+            if os.path.exists(local):
+                msg = "Caching enabled and local cache: %s does not match checksum" % local
+            else:
+                msg = "Caching enabled but no local cache of %s from %s" % (local, self.ui_id)
+            raise Errors.RepoError, msg
+
         try:
             def checkfunc(obj):
                 try:


More information about the Yum-commits mailing list