From d215e2a84591dd3568d13c5fcaa5ba309b4c7994 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 10 Feb 2006 22:07:52 +0000 Subject: avoid unnecessary stat by catching ENOENT error instead of using os.path.exists() svn path=/main/trunk/; revision=2690 --- pym/portage_checksum.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) -- cgit v1.2.3-1-g7c22