X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Futils.py;h=8e06cf35cc6dbbc795b008865c64991b2d9dbfc3;hb=2d0a2a5b3282a61c2749b94f971549b99f60bef8;hp=02278e9130f78579a8e04dea6aef8cd998a55ca8;hpb=aaa9ef21b62dad7f83af44f0b457e9ccc8a938ec;p=dak.git diff --git a/daklib/utils.py b/daklib/utils.py index 02278e91..8e06cf35 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -250,6 +250,7 @@ def check_hash(where, files, hashname, hashfunc): rejmsg = [] for f in files.keys(): + file_handle = None try: file_handle = open_file(f) @@ -264,10 +265,12 @@ def check_hash(where, files, hashname, hashfunc): rejmsg.append("%s: %s check failed in %s" % (f, hashname, where)) except CantOpenError: - # XXX: IS THIS THE BLOODY CASE WHEN THE FILE'S IN THE POOL!? + # TODO: This happens when the file is in the pool. + warn("Cannot open file %s" % f) continue finally: - file_handle.close() + if file_handle: + file_handle.close() return rejmsg ################################################################################ @@ -278,7 +281,15 @@ def check_size(where, files): rejmsg = [] for f in files.keys(): - actual_size = os.stat(f)[stat.ST_SIZE] + try: + entry = os.stat(f) + except OSError, exc: + if exc.errno == 2: + # TODO: This happens when the file is in the pool. + continue + raise + + actual_size = entry[stat.ST_SIZE] size = int(files[f]["size"]) if size != actual_size: rejmsg.append("%s: actual file size (%s) does not match size (%s) in %s"