fix net.oshash for small files

This commit is contained in:
j 2015-03-19 18:57:50 +05:30
parent ed465c527f
commit 72f34f2a60

View file

@ -145,8 +145,9 @@ def oshash(url):
if filesize > 65536:
tail = get_range(url, filesize-65536, filesize)
if filesize < 65536:
for offset in range(0, filesize, bytesize):
buffer = head[offset:offset+bytesize]
f = BytesIO(head)
for x in range(int(filesize/bytesize)):
buffer = f.read(bytesize)
(l_value,)= struct.unpack(longlongformat, buffer)
hash += l_value
hash = hash & 0xFFFFFFFFFFFFFFFF #cut off 64bit overflow