Skip to content

Commit c4c4b6e

Browse files
authored
fix: 修复项目重启后文档状态不正确 (#1754)
1 parent 6bca0a8 commit c4c4b6e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

apps/common/event/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@
1010
from setting.models import Model
1111
from .listener_manage import *
1212

13+
update_document_status_sql = """
14+
UPDATE "public"."document"
15+
SET status ="replace"("replace"("replace"(status, '1', '3'), '0', '3'), '4', '3')
16+
"""
17+
1318

1419
def run():
1520
# QuerySet(Document).filter(status__in=[Status.embedding, Status.queue_up]).update(**{'status': Status.error})
1621
QuerySet(Model).filter(status=setting.models.Status.DOWNLOAD).update(status=setting.models.Status.ERROR,
1722
meta={'message': "下载程序被中断,请重试"})
23+
update_execute(update_document_status_sql, [])

apps/smartdoc/settings/lib.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
@desc:
88
"""
99
import os
10+
import shutil
1011

1112
from smartdoc.const import CONFIG, PROJECT_DIR
1213

@@ -34,6 +35,11 @@
3435
CELERY_WORKER_CANCEL_LONG_RUNNING_TASKS_ON_CONNECTION_LOSS = True
3536
CELERY_ACKS_LATE = True
3637
celery_once_path = os.path.join(celery_data_dir, "celery_once")
38+
try:
39+
if os.path.exists(celery_once_path) and os.path.isdir(celery_once_path):
40+
shutil.rmtree(celery_once_path)
41+
except Exception as e:
42+
pass
3743
CELERY_ONCE = {
3844
'backend': 'celery_once.backends.File',
3945
'settings': {'location': celery_once_path}

0 commit comments

Comments
 (0)