avoid adding the same file multiple times

to the chatbot's files_to_promote list
This commit is contained in:
binary-husky
2023-12-19 19:43:03 +08:00
parent 3c271302cc
commit 9479dd984c
3 changed files with 3 additions and 3 deletions

View File

@@ -583,7 +583,8 @@ def promote_file_to_downloadzone(file, rename_file=None, chatbot=None):
if chatbot is not None:
if 'files_to_promote' in chatbot._cookies: current = chatbot._cookies['files_to_promote']
else: current = []
chatbot._cookies.update({'files_to_promote': [new_path] + current})
if new_path not in current: # 避免把同一个文件添加多次
chatbot._cookies.update({'files_to_promote': [new_path] + current})
return new_path