mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
Handle add/delete file filter operation on non-existent conversation
This commit is contained in:
parent
b3a63017b5
commit
f64f5b3b6e
1 changed files with 4 additions and 0 deletions
|
@ -1320,6 +1320,8 @@ class ConversationAdapters:
|
||||||
def add_files_to_filter(user: KhojUser, conversation_id: str, files: List[str]):
|
def add_files_to_filter(user: KhojUser, conversation_id: str, files: List[str]):
|
||||||
conversation = ConversationAdapters.get_conversation_by_user(user, conversation_id=conversation_id)
|
conversation = ConversationAdapters.get_conversation_by_user(user, conversation_id=conversation_id)
|
||||||
file_list = EntryAdapters.get_all_filenames_by_source(user, "computer")
|
file_list = EntryAdapters.get_all_filenames_by_source(user, "computer")
|
||||||
|
if not conversation:
|
||||||
|
return []
|
||||||
for filename in files:
|
for filename in files:
|
||||||
if filename in file_list and filename not in conversation.file_filters:
|
if filename in file_list and filename not in conversation.file_filters:
|
||||||
conversation.file_filters.append(filename)
|
conversation.file_filters.append(filename)
|
||||||
|
@ -1333,6 +1335,8 @@ class ConversationAdapters:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def remove_files_from_filter(user: KhojUser, conversation_id: str, files: List[str]):
|
def remove_files_from_filter(user: KhojUser, conversation_id: str, files: List[str]):
|
||||||
conversation = ConversationAdapters.get_conversation_by_user(user, conversation_id=conversation_id)
|
conversation = ConversationAdapters.get_conversation_by_user(user, conversation_id=conversation_id)
|
||||||
|
if not conversation:
|
||||||
|
return []
|
||||||
for filename in files:
|
for filename in files:
|
||||||
if filename in conversation.file_filters:
|
if filename in conversation.file_filters:
|
||||||
conversation.file_filters.remove(filename)
|
conversation.file_filters.remove(filename)
|
||||||
|
|
Loading…
Reference in a new issue