Skip to content

Commit

Permalink
remove tmp files in python too, and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
Wazzaps committed Mar 28, 2022
1 parent 75e4f2c commit 9aac208
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ampm/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.2.2'
__version__ = '1.2.3'
7 changes: 6 additions & 1 deletion ampm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def upload(

remote_repo = ArtifactRepo.by_uri(ctx.obj['server'])

# TODO: Remove tmp files
tmp_file_to_remove = None

if local_path is not None:
name = name or local_path.name
Expand All @@ -250,6 +250,7 @@ def upload(

# Compress it
tmp_file = Path(f'/tmp/ampm_tmp_{randbytes(8).hex()}')
tmp_file_to_remove = tmp_file
total_size = ceil(_calc_dir_size(local_path) / 1024)
bar = tqdm.tqdm(
total=total_size,
Expand Down Expand Up @@ -278,6 +279,7 @@ def upload(

# Compress it
tmp_file = Path(f'/tmp/ampm_tmp_{randbytes(8).hex()}')
tmp_file_to_remove = tmp_file
total_size = ceil(local_path.stat().st_size / 1024)
bar = tqdm.tqdm(
total=total_size,
Expand Down Expand Up @@ -328,6 +330,9 @@ def upload(

print(f'{meta.type}:{meta.hash}')

if tmp_file_to_remove is not None:
tmp_file_to_remove.unlink(missing_ok=True)


@cli.command()
@click.option('--remote', is_flag=True, default=False, help='Garbage collect on remote storage instead')
Expand Down

0 comments on commit 9aac208

Please sign in to comment.