2025-04-28 08:31:46 +00:00
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
"""
|
|
|
|
|
|
@project: maxkb
|
|
|
|
|
|
@Author:虎
|
|
|
|
|
|
@file: __init__.py
|
|
|
|
|
|
@date:2023/11/10 10:43
|
|
|
|
|
|
@desc:
|
|
|
|
|
|
"""
|
2025-07-15 09:21:18 +00:00
|
|
|
|
from django.core.cache import cache
|
2025-11-06 08:46:20 +00:00
|
|
|
|
from django.db.models import QuerySet
|
2025-04-28 08:31:46 +00:00
|
|
|
|
from django.utils.translation import gettext as _
|
|
|
|
|
|
|
2025-11-06 08:46:20 +00:00
|
|
|
|
|
2025-07-15 09:21:18 +00:00
|
|
|
|
from ..constants.cache_version import Cache_Version
|
2025-07-02 03:44:33 +00:00
|
|
|
|
from ..db.sql_execute import update_execute
|
2025-07-17 05:24:59 +00:00
|
|
|
|
from ..utils.lock import RedisLock
|
2025-04-28 08:31:46 +00:00
|
|
|
|
|
|
|
|
|
|
update_document_status_sql = """
|
2025-07-02 03:44:33 +00:00
|
|
|
|
UPDATE "public"."document"
|
|
|
|
|
|
SET status ="replace"("replace"("replace"(status, '1', '3'), '0', '3'), '4', '3')
|
|
|
|
|
|
WHERE status ~ '1|0|4' \
|
|
|
|
|
|
"""
|
2025-04-28 08:31:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def run():
|
2025-07-02 03:44:33 +00:00
|
|
|
|
from models_provider.models import Model, Status
|
2025-07-17 05:24:59 +00:00
|
|
|
|
rlock = RedisLock()
|
|
|
|
|
|
if rlock.try_lock('event_init', 30 * 30):
|
2025-04-28 08:31:46 +00:00
|
|
|
|
try:
|
2025-07-02 03:44:33 +00:00
|
|
|
|
# 修改Model状态为ERROR
|
|
|
|
|
|
QuerySet(Model).filter(
|
|
|
|
|
|
status=Status.DOWNLOAD
|
|
|
|
|
|
).update(
|
|
|
|
|
|
status=Status.ERROR, meta={'message': _('The download process was interrupted, please try again')}
|
|
|
|
|
|
)
|
|
|
|
|
|
# 更新文档状态
|
2025-04-28 08:31:46 +00:00
|
|
|
|
update_execute(update_document_status_sql, [])
|
2025-07-15 09:21:18 +00:00
|
|
|
|
version, get_key = Cache_Version.SYSTEM.value
|
|
|
|
|
|
cache.delete(get_key(key='rsa_key'), version=version)
|
2025-04-28 08:31:46 +00:00
|
|
|
|
finally:
|
2025-07-17 05:24:59 +00:00
|
|
|
|
rlock.un_lock('event_init')
|