From 72f34f2a60ce83b1329b0d39902c8b9fe360f6a9 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 19 Mar 2015 18:57:50 +0530 Subject: [PATCH] fix net.oshash for small files --- ox/net.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ox/net.py b/ox/net.py index 200a2b4..3d4c52e 100644 --- a/ox/net.py +++ b/ox/net.py @@ -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