fix: 修复项目重启后文档状态不正确 (#1754)

This commit is contained in:
shaohuzhang1 2024-12-04 12:01:09 +08:00 committed by GitHub
parent 6bca0a8558
commit c4c4b6e9cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -10,8 +10,14 @@ import setting.models
from setting.models import Model
from .listener_manage import *
update_document_status_sql = """
UPDATE "public"."document"
SET status ="replace"("replace"("replace"(status, '1', '3'), '0', '3'), '4', '3')
"""
def run():
# QuerySet(Document).filter(status__in=[Status.embedding, Status.queue_up]).update(**{'status': Status.error})
QuerySet(Model).filter(status=setting.models.Status.DOWNLOAD).update(status=setting.models.Status.ERROR,
meta={'message': "下载程序被中断,请重试"})
update_execute(update_document_status_sql, [])

View File

@ -7,6 +7,7 @@
@desc:
"""
import os
import shutil
from smartdoc.const import CONFIG, PROJECT_DIR
@ -34,6 +35,11 @@ CELERY_TASK_SOFT_TIME_LIMIT = 3600
CELERY_WORKER_CANCEL_LONG_RUNNING_TASKS_ON_CONNECTION_LOSS = True
CELERY_ACKS_LATE = True
celery_once_path = os.path.join(celery_data_dir, "celery_once")
try:
if os.path.exists(celery_once_path) and os.path.isdir(celery_once_path):
shutil.rmtree(celery_once_path)
except Exception as e:
pass
CELERY_ONCE = {
'backend': 'celery_once.backends.File',
'settings': {'location': celery_once_path}