update fileHash

the actual function reads a line at a time instead of in fixed chunks,
but this is fine
master
magical 2024-02-03 01:35:48 -08:00
parent 12a22c8724
commit e7a5af202a
1 changed files with 13 additions and 9 deletions

View File

@ -35,15 +35,19 @@ version = '0.11.6'
def ceiling(num, denom): def ceiling(num, denom):
return -(num // -denom) return -(num // -denom)
def fileHash(fileName): def fileHash(file):
with open(fileName, 'rb') as fh: checksum = 0
hash = 0 try:
with open(file, 'rb') as source:
while True: while True:
s = fh.read(65536) s = source.read(65536)
if not s: if not s:
break break
hash = zlib.crc32(s, hash) checksum = zlib.crc32(s, checksum)
return (hash & 0xFFFFFFFF) except FileNotFoundError:
sys.exit('Error:', file, 'could not be opened.')
return checksum & 0xFFFFFFFF
def enable_item(graph, item): def enable_item(graph, item):
globals()[item] = True globals()[item] = True