Fix update status handling bugs in drop function of json kv storage

This commit is contained in:
yangdx
2025-04-01 13:53:02 +08:00
parent e83f6c0c63
commit ff5c7182da
2 changed files with 20 additions and 6 deletions

View File

@@ -141,8 +141,13 @@ class JsonDocStatusStorage(DocStatusStorage):
None
"""
async with self._storage_lock:
any_deleted = False
for doc_id in doc_ids:
self._data.pop(doc_id, None)
result = self._data.pop(doc_id, None)
if result is not None:
any_deleted = True
if any_deleted:
await set_all_update_flags(self.namespace)
async def drop(self) -> dict[str, str]:
@@ -160,7 +165,9 @@ class JsonDocStatusStorage(DocStatusStorage):
"""
try:
async with self._storage_lock:
self._data.update({})
self._data.clear()
await set_all_update_flags(self.namespace)
await self.index_done_callback()
logger.info(f"Process {os.getpid()} drop {self.namespace}")
return {"status": "success", "message": "data dropped"}

View File

@@ -140,8 +140,13 @@ class JsonKVStorage(BaseKVStorage):
None
"""
async with self._storage_lock:
any_deleted = False
for doc_id in ids:
self._data.pop(doc_id, None)
result = self._data.pop(doc_id, None)
if result is not None:
any_deleted = True
if any_deleted:
await set_all_update_flags(self.namespace)
async def drop_cache_by_modes(self, modes: list[str] | None = None) -> bool:
@@ -183,7 +188,9 @@ class JsonKVStorage(BaseKVStorage):
"""
try:
async with self._storage_lock:
self._data.update({})
self._data.clear()
await set_all_update_flags(self.namespace)
await self.index_done_callback()
logger.info(f"Process {os.getpid()} drop {self.namespace}")
return {"status": "success", "message": "data dropped"}