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

This commit is contained in:
Trenton H
2022-10-31 15:30:56 -07:00
committed by Trenton H
parent 27d1d790f9
commit cce0d363e4
3 changed files with 32 additions and 1 deletions

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