UnisKB/apps/common/event/__init__.py

34 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# coding=utf-8
"""
@project: maxkb
@Author
@file __init__.py
@date2023/11/10 10:43
@desc:
"""
import setting.models
from setting.models import Model
from .listener_manage import *
from django.utils.translation import gettext as _
from ..db.sql_execute import update_execute
from common.lock.impl.file_lock import FileLock
lock = FileLock()
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():
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')