2023-11-16 05:16:27 +00:00
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
"""
|
|
|
|
|
|
@project: maxkb
|
|
|
|
|
|
@Author:虎
|
|
|
|
|
|
@file: __init__.py
|
|
|
|
|
|
@date:2023/11/10 10:43
|
|
|
|
|
|
@desc:
|
|
|
|
|
|
"""
|
2024-03-22 12:18:59 +00:00
|
|
|
|
import setting.models
|
|
|
|
|
|
from setting.models import Model
|
2023-11-16 05:16:27 +00:00
|
|
|
|
from .listener_manage import *
|
2025-01-13 03:15:51 +00:00
|
|
|
|
from django.utils.translation import gettext as _
|
|
|
|
|
|
|
|
|
|
|
|
from ..db.sql_execute import update_execute
|
2025-03-17 09:00:51 +00:00
|
|
|
|
from common.lock.impl.file_lock import FileLock
|
2023-11-16 05:16:27 +00:00
|
|
|
|
|
2025-03-17 09:00:51 +00:00
|
|
|
|
lock = FileLock()
|
2024-12-04 04:01:09 +00:00
|
|
|
|
update_document_status_sql = """
|
|
|
|
|
|
UPDATE "public"."document"
|
|
|
|
|
|
SET status ="replace"("replace"("replace"(status, '1', '3'), '0', '3'), '4', '3')
|
2025-03-17 09:00:51 +00:00
|
|
|
|
WHERE status ~ '1|0|4'
|
2024-12-04 04:01:09 +00:00
|
|
|
|
"""
|
|
|
|
|
|
|
2023-11-16 05:16:27 +00:00
|
|
|
|
|
|
|
|
|
|
def run():
|
2025-03-17 09:00:51 +00:00
|
|
|
|
if lock.try_lock('event_init', 30 * 30):
|
|
|
|
|
|
try:
|
|
|
|
|
|
QuerySet(Model).filter(status=setting.models.Status.DOWNLOAD).update(status=setting.models.Status.ERROR,
|
|
|
|
|
|
meta={'message': _(
|
|
|
|
|
|
'The download process was interrupted, please try again')})
|
|
|
|
|
|
update_execute(update_document_status_sql, [])
|
|
|
|
|
|
finally:
|
|
|
|
|
|
lock.un_lock('event_init')
|