Skip to content

Commit

Permalink
Merge pull request #59 from bo-gan-broadcom/topic/bogan/fix-slow-shasum
Browse files Browse the repository at this point in the history
ova-compose: fix slowness of hashsum generation
  • Loading branch information
oliverkurth authored Apr 29, 2024
2 parents 941d4af + 4dbde2a commit c4e8c5d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ova-compose/ova-compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,10 +1160,14 @@ def write_xml(self, ovf_file=None):


@staticmethod
def _get_hash(filename, hash_type):
def _get_hash(filename, hash_type, blocksz=1024 * 1024):
hash = hashlib.new(hash_type)
with open(filename, "rb") as f:
hash.update(f.read())
while True:
buf = f.read(blocksz)
if not buf:
break
hash.update(buf)
return hash.hexdigest()


Expand Down

0 comments on commit c4e8c5d

Please sign in to comment.