changeset 14156:7668297a2e67

mx: compute sha1 digest blockwise
author Bernhard Urban <bernhard.urban@jku.at>
date Wed, 12 Mar 2014 13:36:23 +0100
parents 1ac6195ee586
children 8c4a3d9308a7 a6595f1b55b0
files mxtool/mx.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mxtool/mx.py	Wed Mar 12 11:45:15 2014 +0100
+++ b/mxtool/mx.py	Wed Mar 12 13:36:23 2014 +0100
@@ -357,8 +357,13 @@
 
     def _sha1OfFile():
         with open(path, 'rb') as f:
-            return hashlib.sha1(f.read()).hexdigest()
-
+            d = hashlib.sha1()
+            while True:
+                buf = f.read(4096)
+                if not buf:
+                    break
+                d.update(buf)
+            return d.hexdigest()
 
     if resolve and mustExist and not exists(path):
         assert not len(urls) == 0, 'cannot find required library ' + name + ' ' + path