From 5ae542613ef0fc9e3992f3620f13b6eb77f4ff10 Mon Sep 17 00:00:00 2001 From: Matt B Date: Sun, 8 Dec 2024 23:17:58 +0800 Subject: [PATCH] fix: Call ChromaDB reset before removing storage directory to fix disk I/O errors --- src/crewai/memory/storage/rag_storage.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/crewai/memory/storage/rag_storage.py b/src/crewai/memory/storage/rag_storage.py index bf40aee96..f652788e7 100644 --- a/src/crewai/memory/storage/rag_storage.py +++ b/src/crewai/memory/storage/rag_storage.py @@ -150,9 +150,14 @@ class RAGStorage(BaseRAGStorage): def reset(self) -> None: try: - shutil.rmtree(f"{db_storage_path()}/{self.type}") + # First reset ChromaDB's internal state if self.app: 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: if "attempt to write a readonly database" in str(e): # Ignore this specific error