Skip to content

Commit

Permalink
Add exception handling to os.remove in the remove-asset-by_pathfang m…
Browse files Browse the repository at this point in the history
…ethod of the avocado/utilities/asset.py file

Signed-off-by: mataotao <[email protected]>
  • Loading branch information
mataotao committed Aug 29, 2024
1 parent 34b427e commit 53cd6e1
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 53cd6e1

Please sign in to comment.