diff options
author | zyp <zyp@localhost> | 2006-11-17 21:08:12 +0100 |
---|---|---|
committer | zyp <zyp@localhost> | 2006-11-17 21:08:12 +0100 |
commit | f02cce5aa1359bba2a717d26d699a58220221c16 (patch) | |
tree | e5fac2effb604925d15128e078cbdba74bf1e531 /pyanidb | |
parent | e7372290e93e2fa26237e2ecbe257c8ccc4dce30 (diff) |
[project @ zyp-20061117200812-d609f675e158ba15]
[project @ 66]
Implemented hashing with additional checksums.
Diffstat (limited to 'pyanidb')
-rw-r--r-- | pyanidb/hash.py | 8 |
1 files changed, 7 insertions, 1 deletions
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): |