Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Catch exception during trash-move
Browse files Browse the repository at this point in the history
  • Loading branch information
tribut committed Feb 20, 2022
1 parent 2c62583 commit f6e65d8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/documents/signals/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,14 @@ def cleanup_document_deletion(sender, instance, using, **kwargs):

logger.debug(
f"Moving {instance.source_path} to trash at {new_file_path}")
os.rename(instance.source_path, new_file_path)
try:
os.rename(instance.source_path, new_file_path)
except OSError as e:
logger.error(
f"Failed to move {instance.source_path} to trash at "
f"{new_file_path}: {e}. Skipping cleanup!"
)
return

for filename in (instance.source_path,
instance.archive_path,
Expand Down

0 comments on commit f6e65d8

Please sign in to comment.