stringio does not have a fastread...

This commit is contained in:
Ryan Tucker 2010-01-06 09:03:08 -05:00
parent dfa9eff725
commit 0694a2e8c7

View file

@ -48,10 +48,16 @@ class MyKey(Key):
@return: MD5 Hash of the file in fp
"""
m = md5.new()
s = fp.fastread(self.BufferSize)
try:
s = fp.fastread(self.BufferSize)
except AttributeError:
s = fp.read(self.BufferSize)
while s:
m.update(s)
s = fp.fastread(self.BufferSize)
try:
s = fp.fastread(self.BufferSize)
except AttributeError:
s = fp.read(self.BufferSize)
self.md5 = m.hexdigest()
self.base64md5 = base64.encodestring(m.digest())
if self.base64md5[-1] == '\n':