Chunk hash calculation in heap_profile.
Change-Id: Ieb9539173b4a87d7f479bf1992bcfdf886de0dd9
diff --git a/tools/heap_profile b/tools/heap_profile
index 74fae7d..42e8a62 100755
--- a/tools/heap_profile
+++ b/tools/heap_profile
@@ -47,10 +47,14 @@
UUID = str(uuid.uuid4())[-6:]
def check_hash(file_name, sha_value):
+ file_hash = hashlib.sha1()
with open(file_name, 'rb') as fd:
- # TODO(fmayer): Chunking.
- file_hash = hashlib.sha1(fd.read()).hexdigest()
- return file_hash == sha_value
+ while True:
+ chunk = fd.read(4096)
+ if not chunk:
+ break
+ file_hash.update(chunk)
+ return file_hash.hexdigest() == sha_value
def load_trace_to_text(platform):