fix net.oshash for small files
This commit is contained in:
parent
ed465c527f
commit
72f34f2a60
1 changed files with 3 additions and 2 deletions
|
@ -145,8 +145,9 @@ def oshash(url):
|
||||||
if filesize > 65536:
|
if filesize > 65536:
|
||||||
tail = get_range(url, filesize-65536, filesize)
|
tail = get_range(url, filesize-65536, filesize)
|
||||||
if filesize < 65536:
|
if filesize < 65536:
|
||||||
for offset in range(0, filesize, bytesize):
|
f = BytesIO(head)
|
||||||
buffer = head[offset:offset+bytesize]
|
for x in range(int(filesize/bytesize)):
|
||||||
|
buffer = f.read(bytesize)
|
||||||
(l_value,)= struct.unpack(longlongformat, buffer)
|
(l_value,)= struct.unpack(longlongformat, buffer)
|
||||||
hash += l_value
|
hash += l_value
|
||||||
hash = hash & 0xFFFFFFFFFFFFFFFF #cut off 64bit overflow
|
hash = hash & 0xFFFFFFFFFFFFFFFF #cut off 64bit overflow
|
||||||
|
|
Loading…
Reference in a new issue