Skip to content

Commit

Permalink
Merge pull request #5979 from faker-king/mtt
Browse files Browse the repository at this point in the history
Add exception handling to os.remove in the remove-asset-by_pathfang method of the avocado/utilities/asset.py file
  • Loading branch information
richtja committed Sep 2, 2024
2 parents e2dea7a + 53cd6e1 commit f1ed1f8
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 f1ed1f8

Please sign in to comment.