Handle permission problems when trying to cache the remote Packages file
authorZac Medico <zmedico@gentoo.org>
Thu, 10 Dec 2009 01:05:49 +0000 (01:05 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 10 Dec 2009 01:05:49 +0000 (01:05 -0000)
from a binhost. Thanks to Jeremy Olexa <darkside@g.o> for reporting.
(trunk r14997)

svn path=/main/branches/2.1.7/; revision=15013

pym/portage/dbapi/bintree.py

index cd5d0b6eb73507d37ccce2d1a286a4a95a5a5234..d4039e39604256aefc183638bf98f3350999b27b 100644 (file)
@@ -739,10 +739,17 @@ class binarytree(object):
                        if pkgindex is rmt_idx:
                                pkgindex.modified = False # don't update the header
                                from portage.util import atomic_ofstream, ensure_dirs
-                               ensure_dirs(os.path.dirname(pkgindex_file))
-                               f = atomic_ofstream(pkgindex_file)
-                               pkgindex.write(f)
-                               f.close()
+                               try:
+                                       ensure_dirs(os.path.dirname(pkgindex_file))
+                                       f = atomic_ofstream(pkgindex_file)
+                                       pkgindex.write(f)
+                                       f.close()
+                               except PortageException:
+                                       if os.access(os.path.join(
+                                               self.settings["ROOT"], CACHE_PATH), os.W_OK):
+                                               raise
+                                       # The current user doesn't have permission to cache the
+                                       # file, but that's alright.
                        if pkgindex:
                                self._remotepkgs = {}
                                for d in pkgindex.packages: