From f02cce5aa1359bba2a717d26d699a58220221c16 Mon Sep 17 00:00:00 2001 From: zyp Date: Fri, 17 Nov 2006 20:08:12 +0000 Subject: [project @ zyp-20061117200812-d609f675e158ba15] [project @ 66] Implemented hashing with additional checksums. --- pyanidb/hash.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'pyanidb') diff --git a/pyanidb/hash.py b/pyanidb/hash.py index d655d53..a748f9e 100644 --- a/pyanidb/hash.py +++ b/pyanidb/hash.py @@ -29,12 +29,18 @@ class File: def write_cache(self): try: + self.clear_cache() xattr.setxattr(self.name, 'user.pyanidb.mtime', str(int(self.mtime))) for n in ('ed2k', 'md5', 'sha1', 'crc32'): if hasattr(self, n): xattr.setxattr(self.name, 'user.pyanidb.' + n, getattr(self, n)) except IOError: pass + + def clear_cache(self): + for name in xattr.listxattr(self.name): + if name.startswith('user.pyanidb.'): + xattr.removexattr(self.name, name) class Hashthread(threading.Thread): def __init__(self, filelist, hashlist, algorithms, cache, *args, **kwargs): @@ -51,7 +57,7 @@ class Hashthread(threading.Thread): except IndexError: return -def hash_files(files, cache = False, num_threads = 1, algorithms = ('ed2k',)): +def hash_files(files, cache = False, algorithms = ('ed2k',), num_threads = 1): hashlist = [] threads = [] for x in xrange(num_threads): -- cgit v1.2.3