提交 7c81123d 编写于 作者: X Xu Han

utils.crypto: Fix dead loop in hash_file function

Fix the dead loop caused by a wrong indentation in the
hash_file function.
Signed-off-by: NXu Han <xuhan@redhat.com>
上级 42ddac8c
...@@ -66,11 +66,11 @@ def hash_file(filename, size=None, algorithm="md5"): ...@@ -66,11 +66,11 @@ def hash_file(filename, size=None, algorithm="md5"):
while size > 0: while size > 0:
if chunksize > size: if chunksize > size:
chunksize = size chunksize = size
data = file_to_hash.read(chunksize) data = file_to_hash.read(chunksize)
if len(data) == 0: if len(data) == 0:
logging.debug("Nothing left to read but size=%d", size) logging.debug("Nothing left to read but size=%d", size)
break break
hash_obj.update(data) hash_obj.update(data)
size -= len(data) size -= len(data)
return hash_obj.hexdigest() return hash_obj.hexdigest()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册