Fix: move files per document during scheduled workflow runs

check_scheduled_workflows runs the workflow once per matched document inside the task-wide file move scope, so every rename it triggered was deferred to the end of the task. A long run killed by the Celery time limit would then discard all of the renames.

The task now flushes the pending file moves after each document's workflow run and websocket notification, the same way bulk_update_documents does, so renames land document by document while the scope stays open.
This commit is contained in:
stumpylog committed 2026-11-09 12:25:21 -08:00
1 parent 1dce32ef9b
commit bc5be28614
2 files changed
+58

No files matched your search

+5
View File
@@ -574,6 +574,8 @@ def check_scheduled_workflows() -> None:
Once a document satisfies this condition, and recurring/non-recurring constraints are met, the workflow is run.
"""
from documents.file_moves import flush_pending_file_moves
scheduled_workflows = get_workflows_for_trigger(
WorkflowTrigger.WorkflowTriggerType.SCHEDULED,
)
@@ -701,6 +703,9 @@ def check_scheduled_workflows() -> None:
sender=None,
document=document,
)
# Move this document's files now rather than at the end
# of the task, so a long run makes steady progress.
flush_pending_file_moves()
def update_document_parent_tags(tag: Tag, new_parent: Tag) -> None: