chdtest.py: Open as binary, read in chunks to reduce memory usage. (nw)

This commit is contained in:
Mike Naberezny 2015-03-06 12:18:30 -08:00
parent c8c37ef19c
commit b32c98689f

View File

@ -30,10 +30,17 @@ def compareInfo(info1, info2):
def sha1sum(path): def sha1sum(path):
if not os.path.exists(path): if not os.path.exists(path):
return "" return ""
sha1 = hashlib.sha1() f = open(path, 'rb')
f = open(path, 'r') try:
sha1.update(f.read()) sha1 = hashlib.sha1()
f.close() while True:
data = f.read(8192)
if data:
sha1.update(data)
else:
break
finally:
f.close()
return sha1.hexdigest() return sha1.hexdigest()
def extractcdAndCompare(type): def extractcdAndCompare(type):