From: Zac Medico Date: Wed, 7 Sep 2011 18:01:14 +0000 (-0700) Subject: egencache: tweak cache dir write access check X-Git-Tag: v2.2.0_alpha55~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4b8614d99da3e4d5ce46c70c944cce5d5d1d9a1f;p=portage.git egencache: tweak cache dir write access check --- diff --git a/bin/egencache b/bin/egencache index 6229ed6cd..7766e786e 100755 --- a/bin/egencache +++ b/bin/egencache @@ -818,21 +818,25 @@ def egencache_main(args): if options.update and 'metadata-transfer' not in settings.features: settings.features.add('metadata-transfer') + settings.lock() + + portdb = portage.portdbapi(mysettings=settings) + if options.update: if options.cache_dir is not None: # already validated earlier pass else: - if os.path.isdir(settings["PORTAGE_DEPCACHEDIR"]) and \ - not os.access(settings["PORTAGE_DEPCACHEDIR"], os.W_OK): + # We check write access after the portdbapi constructor + # has had an opportunity to create it. This ensures that + # we don't use the cache in the "volatile" mode which is + # undesirable for egencache. + if not os.access(settings["PORTAGE_DEPCACHEDIR"], os.W_OK): writemsg_level("ecachegen: error: " + \ "write access denied: %s\n" % (settings["PORTAGE_DEPCACHEDIR"],), level=logging.ERROR, noiselevel=-1) return 1 - settings.lock() - - portdb = portage.portdbapi(mysettings=settings) if options.repo is not None: repo_path = portdb.getRepositoryPath(options.repo) if repo_path is None: