Fix: return the post-move modified time from document updates

Editing a document in a way that renames its file returned a response carrying the modified time from before the move. The deferred file move runs after the response is built and bumps modified, so the stored value was newer than the one the client received. The frontend then saw a newer server modified time and showed a spurious "document was updated" prompt whose reload discarded local edits.

DocumentViewSet.update now flushes pending file moves right after saving and before reading the document back, so the response reflects the final filename and modified time.
This commit is contained in:
stumpylog committed 2026-11-09 12:25:21 -08:00
1 parent a506effaf9
commit f1aac712c6
2 files changed
+30

No files matched your search

+3
View File
@@ -128,6 +128,7 @@ from documents.data_models import ConsumableDocument
from documents.data_models import DocumentMetadataOverrides
from documents.data_models import DocumentSource
from documents.file_handling import format_filename
from documents.file_moves import flush_pending_file_moves
from documents.filters import CorrespondentFilterSet
from documents.filters import CustomFieldFilterSet
from documents.filters import DocumentFilterSet
@@ -1291,6 +1292,8 @@ class DocumentViewSet(
)
serializer.is_valid(raise_exception=True)
self.perform_update(serializer)
# The response must reflect the post-move filename and modified time
flush_pending_file_moves()
if content_updated and content_doc.id != root_doc.id:
content_doc.content = (