refactor: enhance logging and task management in document storage and upload tasks
This commit is contained in:
@@ -2,25 +2,29 @@
|
||||
|
||||
from app.config import settings
|
||||
from app.tasks.retry_config import BaseTaskWithRetry
|
||||
# Import the shared Celery instance
|
||||
from app.celery_app import celery
|
||||
from app.utils import task_logger, log_task
|
||||
|
||||
# 1) Import the aggregator task
|
||||
# Import the aggregator task
|
||||
from app.tasks.send_to_all import send_to_all_destinations
|
||||
|
||||
|
||||
@celery.task(base=BaseTaskWithRetry)
|
||||
@log_task("finalize_storage")
|
||||
def finalize_document_storage(original_file: str, processed_file: str, metadata: dict):
|
||||
"""
|
||||
Final storage step after embedding metadata.
|
||||
We will now call 'send_to_all_destinations' to push the final PDF to Dropbox/Nextcloud/Paperless.
|
||||
"""
|
||||
print(f"[INFO] Finalizing document storage for {processed_file}")
|
||||
task_logger(f"Finalizing document storage for {processed_file}", step_name="finalize_storage")
|
||||
|
||||
# 2) Enqueue uploads to all destinations (Dropbox, Nextcloud, Paperless)
|
||||
send_to_all_destinations.delay(processed_file)
|
||||
# Enqueue uploads to all destinations (Dropbox, Nextcloud, Paperless)
|
||||
send_task = send_to_all_destinations.delay(processed_file)
|
||||
|
||||
task_logger(f"Triggered send to all destinations with task ID: {send_task.id}",
|
||||
step_name="finalize_storage", status="success")
|
||||
|
||||
return {
|
||||
"status": "Completed",
|
||||
"file": processed_file
|
||||
"file": processed_file,
|
||||
"send_task_id": send_task.id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user