From 9f006ec08a8c9b938577422b1a7b9ea9d39cd8d8 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Wed, 13 Jan 2010 08:59:44 +0100 Subject: [PATCH] [#75 state:fixed] md5 hashes are now computed incrementally. --- core/fs.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/fs.py b/core/fs.py index 7fbe8bc1..5c3dc6ff 100644 --- a/core/fs.py +++ b/core/fs.py @@ -102,8 +102,12 @@ class File(object): elif field == 'md5': try: fp = io.open(self.path, 'rb') - filedata = fp.read() - md5 = hashlib.md5(filedata) + md5 = hashlib.md5() + CHUNK_SIZE = 8192 + filedata = fp.read(CHUNK_SIZE) + while filedata: + md5.update(filedata) + filedata = fp.read(CHUNK_SIZE) self.md5 = md5.digest() fp.close() except Exception: