fix: Call ChromaDB reset before removing storage directory to fix disk I/O errors

This commit is contained in:
Matt B
2024-12-08 23:17:58 +08:00
parent c7c0647dd2
commit 5ae542613e

View File

@@ -150,9 +150,14 @@ class RAGStorage(BaseRAGStorage):
def reset(self) -> None: def reset(self) -> None:
try: try:
shutil.rmtree(f"{db_storage_path()}/{self.type}") # First reset ChromaDB's internal state
if self.app: if self.app:
self.app.reset() self.app.reset()
# Then remove the directory
storage_path = f"{db_storage_path()}/{self.type}"
if os.path.exists(storage_path):
shutil.rmtree(storage_path)
except Exception as e: except Exception as e:
if "attempt to write a readonly database" in str(e): if "attempt to write a readonly database" in str(e):
# Ignore this specific error # Ignore this specific error