hashed_path: convert stat OSError to FileNotFound
authorZac Medico <zmedico@gentoo.org>
Sun, 16 Oct 2011 21:13:45 +0000 (14:13 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 16 Oct 2011 21:13:45 +0000 (14:13 -0700)
This makes it consistent with perform_checksum call which also raises
FileNotFound instead of OSError.

pym/portage/dbapi/porttree.py
pym/portage/eclass_cache.py

index 0ade59a199319a6a6974322cac980dabf91115a0..a0b7d7e1f3425de2ddf34109ed9aefd2000e77be 100644 (file)
@@ -424,7 +424,7 @@ class portdbapi(dbapi):
                        # snag mtime since we use it later, and to trigger stat failure
                        # if it doesn't exist
                        ebuild_hash.mtime
-               except OSError:
+               except FileNotFound:
                        writemsg(_("!!! aux_get(): ebuild for " \
                                "'%s' does not exist at:\n") % (cpv,), noiselevel=-1)
                        writemsg("!!!            %s\n" % ebuild_path, noiselevel=-1)
index adfe69ae9add5f0ca098c8c0fbd77031ce90c495..4a934f16f1f80c06ed16e33065704ca76536ded1 100644 (file)
@@ -9,7 +9,7 @@ import sys
 import operator
 from portage.util import normalize_path
 import errno
-from portage.exception import PermissionDenied
+from portage.exception import FileNotFound, PermissionDenied
 from portage import os
 from portage import checksum
 
@@ -30,7 +30,12 @@ class hashed_path(object):
                        # the straight c api.
                        # thus use the defacto python compatibility work around;
                        # access via index, which guarantees you get the raw long.
-                       self.mtime = obj = os.stat(self.location)[stat.ST_MTIME]
+                       try:
+                               self.mtime = obj = os.stat(self.location)[stat.ST_MTIME]
+                       except OSError as e:
+                               if e.errno in (errno.ENOENT, errno.ESTALE):
+                                       raise FileNotFound(self.location)
+                               raise
                        return obj
                if not attr.islower():
                        # we don't care to allow .mD5 as an alias for .md5
@@ -113,7 +118,7 @@ class cache(object):
                                obj.eclass_dir = x
                                try:
                                        mtime = obj.mtime
-                               except OSError:
+                               except FileNotFound:
                                        continue
                                ys=y[:-eclass_len]
                                if x == self._master_eclass_root: