Add deleted websocket message

This commit is contained in:
shamoon
2025-02-01 16:40:39 -08:00
parent bf2c6c4c25
commit eeb9347e99
5 changed files with 43 additions and 1 deletions

View File

@@ -24,6 +24,8 @@ from documents.models import Document
from documents.models import DocumentType
from documents.models import StoragePath
from documents.permissions import set_permissions_for_object
from documents.plugins.helpers import ProgressManager
from documents.plugins.helpers import ProgressStatusOptions
from documents.tasks import bulk_update_documents
from documents.tasks import consume_file
from documents.tasks import update_document_content_maybe_archive_file
@@ -219,6 +221,14 @@ def delete(doc_ids: list[int]) -> Literal["OK"]:
with index.open_index_writer() as writer:
for id in doc_ids:
index.remove_document_by_id(writer, id)
status_mgr = ProgressManager()
status_mgr.send_progress(
status=ProgressStatusOptions.DELETED,
message="Documents deleted",
current_progress=1,
max_progress=1,
)
except Exception as e:
if "Data too long for column" in str(e):
logger.warning(

View File

@@ -13,6 +13,7 @@ class ProgressStatusOptions(str, enum.Enum):
WORKING = "WORKING"
SUCCESS = "SUCCESS"
FAILED = "FAILED"
DELETED = "DELETED"
class ProgressManager:
@@ -21,7 +22,7 @@ class ProgressManager:
of the open/close of the layer to ensure messages go out and everything is cleaned up
"""
def __init__(self, filename: str, task_id: str | None = None) -> None:
def __init__(self, filename: str | None = None, task_id: str | None = None) -> None:
self.filename = filename
self._channel: RedisPubSubChannelLayer | None = None
self.task_id = task_id