vardbapi: use config._init_dirs() when necessary
authorZac Medico <zmedico@gentoo.org>
Wed, 25 May 2011 04:36:36 +0000 (21:36 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 26 May 2011 06:12:38 +0000 (23:12 -0700)
pym/portage/dbapi/vartree.py

index 1db7d9e579b9157baca58645087f03253a462708..aa57ab74fd8c0c9d97e6333e0930403bee080417 100644 (file)
@@ -37,7 +37,7 @@ from portage.const import CACHE_PATH, CONFIG_MEMORY_FILE, \
 from portage.const import _ENABLE_DYN_LINK_MAP, _ENABLE_PRESERVE_LIBS
 from portage.dbapi import dbapi
 from portage.exception import CommandNotFound, \
-       InvalidData, InvalidPackageName, \
+       InvalidData, InvalidLocation, InvalidPackageName, \
        FileNotFound, PermissionDenied, UnsupportedAPIException
 from portage.localization import _
 from portage.util.movefile import movefile
@@ -787,11 +787,12 @@ class vardbapi(dbapi):
                                if incrementing:
                                        #increment counter
                                        counter += 1
-                                       # use same permissions as config._init_dirs()
-                                       ensure_dirs(os.path.dirname(self._counter_path),
-                                               gid=portage_gid, mode=0o2750, mask=0o2)
                                        # update new global counter file
-                                       write_atomic(self._counter_path, str(counter))
+                                       try:
+                                               write_atomic(self._counter_path, str(counter))
+                                       except InvalidLocation:
+                                               self.settings._init_dirs()
+                                               write_atomic(self._counter_path, str(counter))
                                self._cached_counter = counter
                finally:
                        self.unlock()