Make dir_get_metadata() return early if the current user does
authorZac Medico <zmedico@gentoo.org>
Thu, 15 Nov 2007 02:27:30 +0000 (02:27 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 15 Nov 2007 02:27:30 +0000 (02:27 -0000)
not have write access to /var/cache/edb. Thanks to Cardoe for
reporting.

svn path=/main/trunk/; revision=8502

pym/portage/getbinpkg.py

index f5390b9ddcd6214c69cc110cac45a2b1f43b0d6a..87f20552824ad195453e73dd18b796c33e6bb30b 100644 (file)
@@ -455,6 +455,8 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
        else:
                keepconnection = 1
 
+       cache_path = "/var/cache/edb"
+
        if makepickle is None:
                makepickle = "/var/cache/edb/metadata.idx.most_recent"
 
@@ -479,6 +481,11 @@ def dir_get_metadata(baseurl, conn=None, chunk_size=3000, verbose=1, usingcache=
        if not metadata[baseurl].has_key("data"):
                metadata[baseurl]["data"]={}
 
+       if not os.access(cache_path, os.W_OK):
+               sys.stderr.write("!!! Unable to write binary metadata to disk!\n")
+               sys.stderr.write("!!! Permission denied: '%s'\n" % cache_path)
+               return metadata[baseurl]["data"]
+
        filelist = dir_get_list(baseurl, conn)
        tbz2list = match_in_array(filelist, suffix=".tbz2")
        metalist = match_in_array(filelist, prefix="metadata.idx")