Make dir_get_metadata() return early if the current user does
authorZac Medico <zmedico@gentoo.org>
Tue, 20 Nov 2007 23:59:51 +0000 (23:59 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 20 Nov 2007 23:59:51 +0000 (23:59 -0000)
not have write access to /var/cache/edb. Thanks to Cardoe for
reporting. (trunk r8502)

svn path=/main/branches/2.1.2/; revision=8561

pym/getbinpkg.py

index f8529d79e704b812583a254e9d5392d383e6e85d..b57da2ca1fd6af717a1ac798d798862417d574e2 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"
 
@@ -482,6 +484,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")