From d23f7da8e31dd9d535be1ab645186a18a003fc54 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Fri, 5 Apr 2024 13:18:51 +0530 Subject: [PATCH] Handle the case where a previous serach model isn't set when updating the model --- src/khoj/routers/api_config.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/khoj/routers/api_config.py b/src/khoj/routers/api_config.py index e72ba3b8..0eb70981 100644 --- a/src/khoj/routers/api_config.py +++ b/src/khoj/routers/api_config.py @@ -265,7 +265,11 @@ async def update_search_model( prev_config = await adapters.aget_user_search_model(user) new_config = await adapters.aset_user_search_model(user, int(id)) - if int(id) != prev_config.id: + if prev_config and int(id) != prev_config.id and new_config: + await EntryAdapters.adelete_all_entries(user) + + if not prev_config: + # If the use was just using the default config, delete all the entries and set the new config. await EntryAdapters.adelete_all_entries(user) if new_config is None: