From 170588c4abddbde427476bbf6b53534ecac6cd41 Mon Sep 17 00:00:00 2001 From: JessicaTegner Date: Fri, 11 Oct 2024 21:46:23 +0300 Subject: [PATCH] Catching file not found error in remove_latest command --- src/tufup/repo/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/tufup/repo/__init__.py b/src/tufup/repo/__init__.py index 6eef251..0e9dd52 100644 --- a/src/tufup/repo/__init__.py +++ b/src/tufup/repo/__init__.py @@ -832,10 +832,13 @@ def remove_latest_bundle(self): archive_path = self.targets_dir / latest_archive.target_path_str patch_path = archive_path.with_suffix('').with_suffix(SUFFIX_PATCH) for target_path in [archive_path, patch_path]: - removed = self.roles.remove_target(local_path=target_path) - logger.info( + try: + removed = self.roles.remove_target(local_path=target_path) + logger.info( f'target {"removed" if removed else "not found"}: {target_path}' ) + except FileNotFoundError: + logger.warning(f'file not found: {target_path}') def publish_changes(self, private_key_dirs: List[Union[pathlib.Path, str]]): """