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

Commit f6e65d8

Browse files
committed
Catch exception during trash-move
1 parent 2c62583 commit f6e65d8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/documents/signals/handlers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,14 @@ def cleanup_document_deletion(sender, instance, using, **kwargs):
247247

248248
logger.debug(
249249
f"Moving {instance.source_path} to trash at {new_file_path}")
250-
os.rename(instance.source_path, new_file_path)
250+
try:
251+
os.rename(instance.source_path, new_file_path)
252+
except OSError as e:
253+
logger.error(
254+
f"Failed to move {instance.source_path} to trash at "
255+
f"{new_file_path}: {e}. Skipping cleanup!"
256+
)
257+
return
251258

252259
for filename in (instance.source_path,
253260
instance.archive_path,

0 commit comments

Comments
 (0)