mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 06:26:00 +08:00
Delete Corresponding Minio Bucket When Deleting a Knowledge Base (#7841)
### What problem does this PR solve? Delete Corresponding Minio Bucket When Deleting a Knowledge Base [issue #4113 ](https://github.com/infiniflow/ragflow/issues/4113) ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
552023ee4b
commit
2f4d803db1
@ -34,6 +34,7 @@ from api import settings
|
|||||||
from rag.nlp import search
|
from rag.nlp import search
|
||||||
from api.constants import DATASET_NAME_LIMIT
|
from api.constants import DATASET_NAME_LIMIT
|
||||||
from rag.settings import PAGERANK_FLD
|
from rag.settings import PAGERANK_FLD
|
||||||
|
from rag.utils.storage_factory import STORAGE_IMPL
|
||||||
|
|
||||||
|
|
||||||
@manager.route('/create', methods=['post']) # noqa: F821
|
@manager.route('/create', methods=['post']) # noqa: F821
|
||||||
@ -226,6 +227,8 @@ def rm():
|
|||||||
for kb in kbs:
|
for kb in kbs:
|
||||||
settings.docStoreConn.delete({"kb_id": kb.id}, search.index_name(kb.tenant_id), kb.id)
|
settings.docStoreConn.delete({"kb_id": kb.id}, search.index_name(kb.tenant_id), kb.id)
|
||||||
settings.docStoreConn.deleteIdx(search.index_name(kb.tenant_id), kb.id)
|
settings.docStoreConn.deleteIdx(search.index_name(kb.tenant_id), kb.id)
|
||||||
|
if hasattr(STORAGE_IMPL, 'remove_bucket'):
|
||||||
|
STORAGE_IMPL.remove_bucket(kb.id)
|
||||||
return get_json_result(data=True)
|
return get_json_result(data=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return server_error_response(e)
|
return server_error_response(e)
|
||||||
|
@ -118,3 +118,13 @@ class RAGFlowMinio:
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def remove_bucket(self, bucket):
|
||||||
|
try:
|
||||||
|
if self.conn.bucket_exists(bucket):
|
||||||
|
objects_to_delete = self.conn.list_objects(bucket, recursive=True)
|
||||||
|
for obj in objects_to_delete:
|
||||||
|
self.conn.remove_object(bucket, obj.object_name)
|
||||||
|
self.conn.remove_bucket(bucket)
|
||||||
|
except Exception:
|
||||||
|
logging.exception(f"Fail to remove bucket {bucket}")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user