[Pkg-bazaar-commits] ./bzr/unstable r320: - Compute SHA-1 of files in chunks
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 07:43:49 UTC 2009
------------------------------------------------------------
revno: 320
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Mon 2005-05-02 14:41:03 +1000
message:
- Compute SHA-1 of files in chunks
modified:
bzrlib/osutils.py
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2005-05-02 04:37:13 +0000
+++ b/bzrlib/osutils.py 2005-05-02 04:41:03 +0000
@@ -92,11 +92,15 @@
def sha_file(f):
import sha
- ## TODO: Maybe read in chunks to handle big files
if hasattr(f, 'tell'):
assert f.tell() == 0
s = sha.new()
- s.update(f.read())
+ BUFSIZE = 128<<10
+ while True:
+ b = f.read(BUFSIZE)
+ if not b:
+ break
+ s.update(b)
return s.hexdigest()
@@ -223,7 +227,6 @@
def compare_files(a, b):
"""Returns true if equal in contents"""
- # TODO: don't read the whole thing in one go.
BUFSIZE = 4096
while True:
ai = a.read(BUFSIZE)
More information about the Pkg-bazaar-commits
mailing list