Add pipeline status validation before document deletion
This commit is contained in:
parent
98e964dfc4
commit
9d7b7981ce
1 changed files with 26 additions and 5 deletions
|
|
@ -2961,11 +2961,7 @@ class LightRAG:
|
||||||
- `status_code` (int): HTTP status code (e.g., 200, 404, 500).
|
- `status_code` (int): HTTP status code (e.g., 200, 404, 500).
|
||||||
- `file_path` (str | None): The file path of the deleted document, if available.
|
- `file_path` (str | None): The file path of the deleted document, if available.
|
||||||
"""
|
"""
|
||||||
deletion_operations_started = False
|
# Get pipeline status shared data and lock for validation
|
||||||
original_exception = None
|
|
||||||
doc_llm_cache_ids: list[str] = []
|
|
||||||
|
|
||||||
# Get pipeline status shared data and lock for status updates
|
|
||||||
pipeline_status = await get_namespace_data(
|
pipeline_status = await get_namespace_data(
|
||||||
"pipeline_status", workspace=self.workspace
|
"pipeline_status", workspace=self.workspace
|
||||||
)
|
)
|
||||||
|
|
@ -2973,6 +2969,31 @@ class LightRAG:
|
||||||
"pipeline_status", workspace=self.workspace
|
"pipeline_status", workspace=self.workspace
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Validate pipeline status before proceeding with deletion
|
||||||
|
async with pipeline_status_lock:
|
||||||
|
if not pipeline_status.get("busy", False):
|
||||||
|
return DeletionResult(
|
||||||
|
status="not_allowed",
|
||||||
|
doc_id=doc_id,
|
||||||
|
message="Deletion not allowed: pipeline is not busy",
|
||||||
|
status_code=403,
|
||||||
|
file_path=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
job_name = pipeline_status.get("job_name", "").lower()
|
||||||
|
if "deleting" not in job_name or "document" not in job_name:
|
||||||
|
return DeletionResult(
|
||||||
|
status="not_allowed",
|
||||||
|
doc_id=doc_id,
|
||||||
|
message=f"Deletion not allowed: current job '{pipeline_status.get('job_name')}' is not a document deletion job",
|
||||||
|
status_code=403,
|
||||||
|
file_path=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
deletion_operations_started = False
|
||||||
|
original_exception = None
|
||||||
|
doc_llm_cache_ids: list[str] = []
|
||||||
|
|
||||||
async with pipeline_status_lock:
|
async with pipeline_status_lock:
|
||||||
log_message = f"Starting deletion process for document {doc_id}"
|
log_message = f"Starting deletion process for document {doc_id}"
|
||||||
logger.info(log_message)
|
logger.info(log_message)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue