diff --git a/modules/models/base_model.py b/modules/models/base_model.py index 268d41e7..98ff8806 100644 --- a/modules/models/base_model.py +++ b/modules/models/base_model.py @@ -1111,8 +1111,8 @@ def delete_chat_history(self, filename): md_history_file_path = history_file_path[:-5] + ".md" # check if history file path matches user_name # if user access control is not enabled, user_name is empty, don't check - assert os.path.dirname(history_file_path) == self.user_name or self.user_name == "" - assert os.path.dirname(md_history_file_path) == self.user_name or self.user_name == "" + assert os.path.basename(os.path.dirname(history_file_path)) == self.user_name or self.user_name == "" + assert os.path.basename(os.path.dirname(md_history_file_path)) == self.user_name or self.user_name == "" try: os.remove(history_file_path) os.remove(md_history_file_path) diff --git a/modules/utils.py b/modules/utils.py index dd778041..24afe763 100644 --- a/modules/utils.py +++ b/modules/utils.py @@ -420,7 +420,7 @@ def save_file(filename, model, chatbot): # check if history file path matches user_name # if user access control is not enabled, user_name is empty, don't check - assert os.path.dirname(history_file_path) == model.user_name or model.user_name == "" + assert os.path.basename(os.path.dirname(history_file_path)) == model.user_name or model.user_name == "" with open(history_file_path, "w", encoding="utf-8") as f: json.dump(json_s, f, ensure_ascii=False, indent=4)