diff --git a/ampm/__init__.py b/ampm/__init__.py index 923b987..5a5df3b 100644 --- a/ampm/__init__.py +++ b/ampm/__init__.py @@ -1 +1 @@ -__version__ = '1.2.2' +__version__ = '1.2.3' diff --git a/ampm/cli.py b/ampm/cli.py index aff6f36..8482933 100644 --- a/ampm/cli.py +++ b/ampm/cli.py @@ -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 @@ -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, @@ -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, @@ -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')