summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzyp <zyp@localhost>2006-10-19 17:54:21 +0200
committerzyp <zyp@localhost>2006-10-19 17:54:21 +0200
commit077ce424d11c8344dc4d95bc5b5fa88d67adf643 (patch)
treead865a76c0b6372e14d9f61661a841668a858c8c
parent46d16b70e87aa2c7acb1786480ed2bf0a4c09772 (diff)
[project @ zyp-20061019155421-ad427e9a8f491d9c]
[project @ 60] Using multihash.hash_file().
-rw-r--r--pyanidb/hash.py12
1 files changed, 1 insertions, 11 deletions
diff --git a/pyanidb/hash.py b/pyanidb/hash.py
index 35c05ae..70f49af 100644
--- a/pyanidb/hash.py
+++ b/pyanidb/hash.py
@@ -1,15 +1,5 @@
import multihash, threading, time
-def file_hash(name, algorithms):
- h = multihash.Multihash(*algorithms)
- f = open(name)
- data = f.read(32768)
- while data:
- h.update(data)
- data = f.read(32768)
- f.close()
- return h
-
class Hashthread(threading.Thread):
def __init__(self, filelist, hashlist, algorithms, *args, **kwargs):
self.filelist = filelist
@@ -20,7 +10,7 @@ class Hashthread(threading.Thread):
try:
while 1:
f = self.filelist.pop(0)
- h = file_hash(f, self.algorithms)
+ h = multihash.hash_file(f, self.algorithms)
self.hashlist.append((f, h))
except IndexError:
return