avoid unnecessary stat by catching ENOENT error instead of using os.path.exists()
authorZac Medico <zmedico@gentoo.org>
Fri, 10 Feb 2006 22:07:52 +0000 (22:07 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 10 Feb 2006 22:07:52 +0000 (22:07 -0000)
svn path=/main/trunk/; revision=2690

pym/portage_checksum.py

index f837966bcf5672143d28b68dbdda489e388ef95c..a11dbc4f6ce1472893e0b865f969b0c39df3d6fb 100644 (file)
@@ -6,6 +6,7 @@
 
 from portage_const import PRIVATE_PATH,PRELINK_BINARY,HASHING_BLOCKSIZE
 import os
+import errno
 import shutil
 import stat
 import portage_exception
@@ -134,8 +135,13 @@ def perform_checksum(filename, hash_function=md5hash, calc_prelink=0):
        myhash, mysize = hash_function(myfilename)
 
        if calc_prelink and prelink_capable:
-               if os.path.exists(prelink_tmpfile):
+               try:
                        os.unlink(prelink_tmpfile)
+               except OSError, oe:
+                       if oe.errno == errno.ENOENT:
+                               pass
+                       else:
+                               raise oe
                portage_locks.unlockfile(mylock)
 
        return (myhash,mysize)