update fileHash
the actual function reads a line at a time instead of in fixed chunks, but this is finemaster
parent
12a22c8724
commit
e7a5af202a
|
@ -35,15 +35,19 @@ version = '0.11.6'
|
|||
def ceiling(num, denom):
|
||||
return -(num // -denom)
|
||||
|
||||
def fileHash(fileName):
|
||||
with open(fileName, 'rb') as fh:
|
||||
hash = 0
|
||||
def fileHash(file):
|
||||
checksum = 0
|
||||
try:
|
||||
with open(file, 'rb') as source:
|
||||
while True:
|
||||
s = fh.read(65536)
|
||||
s = source.read(65536)
|
||||
if not s:
|
||||
break
|
||||
hash = zlib.crc32(s, hash)
|
||||
return (hash & 0xFFFFFFFF)
|
||||
checksum = zlib.crc32(s, checksum)
|
||||
except FileNotFoundError:
|
||||
sys.exit('Error:', file, 'could not be opened.')
|
||||
return checksum & 0xFFFFFFFF
|
||||
|
||||
|
||||
def enable_item(graph, item):
|
||||
globals()[item] = True
|
||||
|
|
Loading…
Reference in New Issue