mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:12:51 +00:00
36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
# coding=utf-8
|
||
"""
|
||
@project: maxkb
|
||
@Author:虎
|
||
@file: __init__.py
|
||
@date:2023/11/10 10:43
|
||
@desc:
|
||
"""
|
||
from django.utils.translation import gettext as _
|
||
|
||
from .listener_manage import *
|
||
from ..db.sql_execute import update_execute
|
||
|
||
update_document_status_sql = """
|
||
UPDATE "public"."document"
|
||
SET status ="replace"("replace"("replace"(status, '1', '3'), '0', '3'), '4', '3')
|
||
WHERE status ~ '1|0|4' \
|
||
"""
|
||
|
||
|
||
def run():
|
||
from models_provider.models import Model, Status
|
||
|
||
if try_lock('event_init', 30 * 30):
|
||
try:
|
||
# 修改Model状态为ERROR
|
||
QuerySet(Model).filter(
|
||
status=Status.DOWNLOAD
|
||
).update(
|
||
status=Status.ERROR, meta={'message': _('The download process was interrupted, please try again')}
|
||
)
|
||
# 更新文档状态
|
||
update_execute(update_document_status_sql, [])
|
||
finally:
|
||
un_lock('event_init')
|