fix perform_checksum.perform_checksum() so that it wraps FileNotFound exceptions
authorZac Medico <zmedico@gentoo.org>
Sun, 12 Feb 2006 11:55:48 +0000 (11:55 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 12 Feb 2006 11:55:48 +0000 (11:55 -0000)
svn path=/main/trunk/; revision=2697

pym/portage.py
pym/portage_checksum.py

index 0a9186b5a4ccbed450c815fc109a83c0201ccc86..4c574b3f0a07e052240586361b9e9e1c9233465d 100644 (file)
@@ -5780,13 +5780,11 @@ class dblink:
                                        mymd5 = None
                                        try:
                                                mymd5 = portage_checksum.perform_md5(obj, calc_prelink=1)
-                                       except (OSError,IOError), e:
-                                               if e.errno == errno.ENOENT:
-                                                       # the file has disappeared between now and our stat call
-                                                       writemsg_stdout("--- !obj   %s %s\n" % ("obj", obj))
-                                                       continue
-                                               else:
-                                                       raise e
+                                       except portage_exception.FileNotFound, e:
+                                               # the file has disappeared between now and our stat call
+                                               writemsg_stdout("--- !obj   %s %s\n" % ("obj", obj))
+                                               continue
+
                                        # string.lower is needed because db entries used to be in upper-case.  The
                                        # string.lower allows for backwards compatibility.
                                        if mymd5 != string.lower(pkgfiles[objkey][2]):
index a11dbc4f6ce1472893e0b865f969b0c39df3d6fb..2dd447df20f6b049c7fcf60843f49031280d00e1 100644 (file)
@@ -131,9 +131,13 @@ def perform_checksum(filename, hash_function=md5hash, calc_prelink=0):
                if retval==0:
                        #portage_util.writemsg(">>> prelink checksum '"+str(filename)+"'.\n")
                        myfilename=prelink_tmpfile
-
-       myhash, mysize = hash_function(myfilename)
-
+       try:
+               myhash, mysize = hash_function(myfilename)
+       except (OSError, IOError), e:
+               if e.errno == errno.ENOENT:
+                       raise portage_exception.FileNotFound(e)
+               else:
+                       raise e
        if calc_prelink and prelink_capable:
                try:
                        os.unlink(prelink_tmpfile)