From 4b8614d99da3e4d5ce46c70c944cce5d5d1d9a1f Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 7 Sep 2011 11:01:14 -0700 Subject: egencache: tweak cache dir write access check --- bin/egencache | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'bin') 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: -- cgit v1.2.3-1-g7c22