Use portage.util.apply_permissions() inside _ensure_access().
authorZac Medico <zmedico@gentoo.org>
Mon, 22 Jun 2009 05:07:45 +0000 (05:07 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 22 Jun 2009 05:07:45 +0000 (05:07 -0000)
svn path=/main/trunk/; revision=13662

pym/portage/cache/fs_template.py

index ee8964e7085dbdc8485bdda363655eaa0876950b..d41749186c1f80754333f126f58ca532e3e73ee6 100644 (file)
@@ -5,7 +5,14 @@
 
 import os
 from portage.cache import template
-from portage.data import portage_gid
+
+import portage.proxy.lazyimport
+import portage.proxy as proxy
+proxy.lazyimport.lazyimport(globals(),
+       'portage.data:portage_gid',
+       'portage.exception:PortageException',
+       'portage.util:apply_permissions',
+)
 
 class FsBased(template.database):
        """template wrapping fs needed options, and providing _ensure_access as a way to 
@@ -34,14 +41,11 @@ class FsBased(template.database):
                """returns true or false if it's able to ensure that path is properly chmod'd and chowned.
                if mtime is specified, attempts to ensure that's correct also"""
                try:
-                       if self._gid != -1:
-                               os.chown(path, -1, self._gid)
-                       if self._perms != -1:
-                               os.chmod(path, self._perms)
+                       apply_permissions(path, gid=self._gid, mode=self._perms)
                        if mtime != -1:
                                mtime=long(mtime)
                                os.utime(path, (mtime, mtime))
-               except (OSError, IOError):
+               except (PortageException, EnvironmentError):
                        return False
                return True