X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Futils.py;h=03135e72e4a58fe99dc9ad05c8506c707957d55f;hb=dc5d7b44188e95d81eb5a43b41c5534dc2e552b0;hp=02278e9130f78579a8e04dea6aef8cd998a55ca8;hpb=95f05e8aac2673dadfef6aed999551d60cb6d322;p=dak.git diff --git a/daklib/utils.py b/daklib/utils.py index 02278e91..03135e72 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -250,24 +250,28 @@ def check_hash(where, files, hashname, hashfunc): rejmsg = [] for f in files.keys(): + file_handle = None try: - file_handle = open_file(f) - - # Check for the hash entry, to not trigger a KeyError. - if not files[f].has_key(hash_key(hashname)): - rejmsg.append("%s: misses %s checksum in %s" % (f, hashname, - where)) + try: + file_handle = open_file(f) + + # Check for the hash entry, to not trigger a KeyError. + if not files[f].has_key(hash_key(hashname)): + rejmsg.append("%s: misses %s checksum in %s" % (f, hashname, + where)) + continue + + # Actually check the hash for correctness. + if hashfunc(file_handle) != files[f][hash_key(hashname)]: + rejmsg.append("%s: %s check failed in %s" % (f, hashname, + where)) + except CantOpenError: + # TODO: This happens when the file is in the pool. + warn("Cannot open file %s" % f) continue - - # Actually check the hash for correctness. - if hashfunc(file_handle) != files[f][hash_key(hashname)]: - 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!? - continue finally: - file_handle.close() + if file_handle: + file_handle.close() return rejmsg ################################################################################ @@ -278,7 +282,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"