Skip to content

Commit

Permalink
Add exception handling to os.remove
Browse files Browse the repository at this point in the history
Signed-off-by: mataotao <[email protected]>
  • Loading branch information
mataotao committed Jul 26, 2024
1 parent 1051bc0 commit ebaa13f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions avocado/utils/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,14 @@ def remove_asset_by_path(cls, asset_path):
:param asset_path: full path of the asset file.
"""
os.remove(asset_path)
filename = f"{asset_path}-CHECKSUM"
os.remove(filename)
try:
os.remove(asset_path)
filename = f"{asset_path}-CHECKSUM"
os.remove(filename)
except FileNotFoundError:
LOG.error(f"File not found: {asset_path} or its checksum file.")
except Exception as e:
LOG.error(f"An error occurred while removing files: {e}")

@property
def urls(self):
Expand Down

0 comments on commit ebaa13f

Please sign in to comment.