Skip to content

Commit

Permalink
Merge pull request #210 from shakenfist/bug-209
Browse files Browse the repository at this point in the history
Correct progress bar for artifact checksumming.
  • Loading branch information
mikalstill authored Jan 6, 2023
2 parents 4de5f11 + 26709b3 commit f26abe3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions shakenfist_client/commandline/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ def artifact_upload(ctx, name=None, source=None, source_url=None, not_shared=Tru
st = os.stat(source)

sha512_hash = hashlib.sha512()
total = 0
with open(source, 'rb') as f:
with tqdm(total=st.st_size, unit='B', unit_scale=True,
desc='Calculate checksum') as pbar:
d = f.read(4096)
while d:
total += len(d)
sha512_hash.update(d)
pbar.update(total)
pbar.update(len(d))
d = f.read(4096)

print('Searching for a pre-existing blob with this hash...')
Expand Down Expand Up @@ -128,6 +126,7 @@ def artifact_upload(ctx, name=None, source=None, source_url=None, not_shared=Tru

d = f.read(buffer_size)

print('Creating artifact')
s = not not_shared
artifact = ctx.obj['CLIENT'].upload_artifact(
name, upload['uuid'], source_url=source_url, shared=s, namespace=namespace)
Expand Down

0 comments on commit f26abe3

Please sign in to comment.