Refresh the instance from the database before doing any file handling with it

This commit is contained in:
Trenton H authored and Trenton H committed 2022-11-03 11:32:27 -07:00
1 parent 3c325582d9
commit 7e3e0a0fa6
3 files changed
+32 -1

No files matched your search

+7
View File
@@ -400,6 +400,13 @@ def update_filename_and_move_files(sender, instance, **kwargs):
with FileLock(settings.MEDIA_LOCK):
try:
# If this was waiting for the lock, the filename or archive_filename
# of this document may have been updated. This happens if multiple updates
# get queued from the UI for the same document
# So freshen up the data before doing anything
instance.refresh_from_db()
old_filename = instance.filename
old_source_path = instance.source_path