From: Zac Medico Date: Fri, 10 Feb 2006 22:07:52 +0000 (-0000) Subject: avoid unnecessary stat by catching ENOENT error instead of using os.path.exists() X-Git-Tag: v2.1_pre5_2760~60 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d215e2a84591dd3568d13c5fcaa5ba309b4c7994;p=portage.git avoid unnecessary stat by catching ENOENT error instead of using os.path.exists() svn path=/main/trunk/; revision=2690 --- diff --git a/pym/portage_checksum.py b/pym/portage_checksum.py index f837966bc..a11dbc4f6 100644 --- a/pym/portage_checksum.py +++ b/pym/portage_checksum.py @@ -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)