From f64f5b3b6e7256d1bb1951accce73ca4c89015cb Mon Sep 17 00:00:00 2001 From: Debanjum Date: Wed, 30 Oct 2024 02:23:34 -0700 Subject: [PATCH] Handle add/delete file filter operation on non-existent conversation --- src/khoj/database/adapters/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/khoj/database/adapters/__init__.py b/src/khoj/database/adapters/__init__.py index f102648b..3bbb1e31 100644 --- a/src/khoj/database/adapters/__init__.py +++ b/src/khoj/database/adapters/__init__.py @@ -1320,6 +1320,8 @@ class ConversationAdapters: def add_files_to_filter(user: KhojUser, conversation_id: str, files: List[str]): conversation = ConversationAdapters.get_conversation_by_user(user, conversation_id=conversation_id) file_list = EntryAdapters.get_all_filenames_by_source(user, "computer") + if not conversation: + return [] for filename in files: if filename in file_list and filename not in conversation.file_filters: conversation.file_filters.append(filename) @@ -1333,6 +1335,8 @@ class ConversationAdapters: @staticmethod def remove_files_from_filter(user: KhojUser, conversation_id: str, files: List[str]): conversation = ConversationAdapters.get_conversation_by_user(user, conversation_id=conversation_id) + if not conversation: + return [] for filename in files: if filename in conversation.file_filters: conversation.file_filters.remove(filename)