summaryrefslogtreecommitdiffstatshomepage
path: root/src/regtests
diff options
context:
space:
mode:
author Mike Naberezny <mike@naberezny.com>2015-03-06 12:18:30 -0800
committer Mike Naberezny <mike@naberezny.com>2015-03-06 12:18:30 -0800
commitb32c98689f1093fb2febcccd73a13e426df44350 (patch)
treecc1d00662528ef9372fa8e0ab42e4740eec7f9b2 /src/regtests
parentc8c37ef19cda81728433b6604b6864a5a6296cf4 (diff)
chdtest.py: Open as binary, read in chunks to reduce memory usage. (nw)
Diffstat (limited to 'src/regtests')
-rw-r--r--src/regtests/chdman/chdtest.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/regtests/chdman/chdtest.py b/src/regtests/chdman/chdtest.py
index 78ed7cbe746..8a09018432a 100644
--- a/src/regtests/chdman/chdtest.py
+++ b/src/regtests/chdman/chdtest.py
@@ -30,10 +30,17 @@ def compareInfo(info1, info2):
def sha1sum(path):
if not os.path.exists(path):
return ""
- sha1 = hashlib.sha1()
- f = open(path, 'r')
- sha1.update(f.read())
- f.close()
+ f = open(path, 'rb')
+ try:
+ sha1 = hashlib.sha1()
+ while True:
+ data = f.read(8192)
+ if data:
+ sha1.update(data)
+ else:
+ break
+ finally:
+ f.close()
return sha1.hexdigest()
def extractcdAndCompare(type):