mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-04-16 21:19:00 +00:00
fix(tasks): use TriggerSource enum values at all apply_async call sites
Replace raw strings ("system", "manual") with PaperlessTask.TriggerSource
enum values in the three callers that can import models. The settings
file remains a raw string (models cannot be imported at settings load
time) with a comment pointing to the enum value it must match.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3951,7 +3951,7 @@ class TasksViewSet(ReadOnlyModelViewSet[PaperlessTask]):
|
||||
task_func, task_kwargs = self._RUNNABLE_TASKS[task_type]
|
||||
async_result = task_func.apply_async(
|
||||
kwargs=task_kwargs,
|
||||
headers={"trigger_source": "manual"},
|
||||
headers={"trigger_source": PaperlessTask.TriggerSource.MANUAL},
|
||||
)
|
||||
return Response({"task_id": async_result.id})
|
||||
except Exception as e:
|
||||
|
||||
@@ -183,6 +183,7 @@ def parse_beat_schedule() -> dict:
|
||||
"schedule": crontab(minute, hour, day_week, day_month, month),
|
||||
"options": {
|
||||
**task["options"],
|
||||
# PaperlessTask.TriggerSource.SCHEDULED -- models can't be imported here
|
||||
"headers": {"trigger_source": "scheduled"},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ from rest_framework.response import Response
|
||||
from rest_framework.throttling import ScopedRateThrottle
|
||||
from rest_framework.viewsets import ModelViewSet
|
||||
|
||||
from documents.models import PaperlessTask
|
||||
from documents.permissions import PaperlessObjectPermissions
|
||||
from documents.tasks import llmindex_index
|
||||
from paperless.filters import GroupFilterSet
|
||||
@@ -429,7 +430,7 @@ class ApplicationConfigurationViewSet(ModelViewSet[ApplicationConfiguration]):
|
||||
# AI index was just enabled and vector store file does not exist
|
||||
llmindex_index.apply_async(
|
||||
kwargs={"rebuild": True},
|
||||
headers={"trigger_source": "system"},
|
||||
headers={"trigger_source": PaperlessTask.TriggerSource.SYSTEM},
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ def queue_llm_index_update_if_needed(*, rebuild: bool, reason: str) -> bool:
|
||||
|
||||
llmindex_index.apply_async(
|
||||
kwargs={"rebuild": rebuild},
|
||||
headers={"trigger_source": "system"},
|
||||
headers={"trigger_source": PaperlessTask.TriggerSource.SYSTEM},
|
||||
)
|
||||
logger.warning(
|
||||
"Queued LLM index update%s: %s",
|
||||
|
||||
Reference in New Issue
Block a user