From 3ca4e5c260523c8c98c7d39d4954e41cf3baa192 Mon Sep 17 00:00:00 2001 From: hbertrand Date: Wed, 25 Oct 2023 13:40:50 -0400 Subject: [PATCH] confirmation --- buster/documents_manager/service.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/buster/documents_manager/service.py b/buster/documents_manager/service.py index 3cd8a30..920c7bc 100644 --- a/buster/documents_manager/service.py +++ b/buster/documents_manager/service.py @@ -87,7 +87,12 @@ def drop_db(self): For Pinecone, this means deleting everything in the namespace. For Mongo DB, this means dropping the database. However this needs to be done manually through the GUI. """ - self.index.delete(namespace=self.namespace, delete_all=True) + confirmation = input("Dropping the database is irreversible. Are you sure you want to proceed? (Y/n): ") - logging.info(f"Deleted all documents from Pinecone namespace: {self.namespace=}") - logging.info(f"The MongoDB database needs to be dropped manually: {self.mongo_db_name=}") + if confirmation.strip().lower() == "y": + self.index.delete(namespace=self.namespace, delete_all=True) + + logging.info(f"Deleted all documents from Pinecone namespace: {self.namespace=}") + logging.info(f"The MongoDB database needs to be dropped manually: {self.mongo_db_name=}") + else: + logging.info("Operation cancelled.")