Fix cacheddir() to behave properly if os.listdir() raises errno.EACCES (Permission...
authorZac Medico <zmedico@gentoo.org>
Tue, 19 Jun 2007 21:59:55 +0000 (21:59 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 19 Jun 2007 21:59:55 +0000 (21:59 -0000)
svn path=/main/trunk/; revision=6879

pym/portage/__init__.py

index ed440bcbebaa7f50b866c875071e4f11c8fe07e6..31f2f091c7c678d3f889948e91b6d9eee234b967 100644 (file)
@@ -193,7 +193,15 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli
        if mtime != cached_mtime or time.time() - mtime < 4:
                if dircache.has_key(mypath):
                        cacheStale += 1
-               list = os.listdir(mypath)
+               try:
+                       list = os.listdir(mypath)
+               except EnvironmentError, e:
+                       if e.errno != errno.EACCES:
+                               raise
+                       del e
+                       if EmptyOnError:
+                               return [], []
+                       raise portage.exception.PermissionDenied(mypath)
                ftype = []
                for x in list:
                        try: