Skip to content

Commit

Permalink
check results exist then delete; error message include dataset key wh…
Browse files Browse the repository at this point in the history
…en unable to delete

sometimes log files are left behind because FileNotFoundError was raised on the results_path
  • Loading branch information
dale-wahl committed Feb 4, 2025
1 parent 0983a36 commit 638413a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common/lib/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,14 +549,17 @@ def delete(self, commit=True):

# delete from drive
try:
self.get_results_path().unlink()
if self.get_results_path().exists():
self.get_results_path().unlink()
if self.get_results_path().with_suffix(".log").exists():
self.get_results_path().with_suffix(".log").unlink()
if self.get_results_folder_path().exists():
shutil.rmtree(self.get_results_folder_path())
except FileNotFoundError:
# already deleted, apparently
pass
except PermissionError as e:
self.db.log.error(f"Could not delete all dataset {self.key} files; they may need to be deleted manually: {e}")

def update_children(self, **kwargs):
"""
Expand Down

0 comments on commit 638413a

Please sign in to comment.