mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-04-05 14:45:28 +00:00
Safer usage of mkdir across the project
This commit is contained in:
parent
8689d7ecea
commit
0d1597616f
16 changed files with 240 additions and 206 deletions
|
|
@ -197,7 +197,9 @@ def handle_new_prompt():
|
|||
|
||||
# Create the new prompt file
|
||||
prompt_path = Path("user_data/logs/notebook") / f"{new_name}.txt"
|
||||
prompt_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
if not prompt_path.parent.exists():
|
||||
prompt_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
prompt_path.write_text("In this story,", encoding='utf-8')
|
||||
|
||||
return gr.update(choices=utils.get_available_prompts(), value=new_name)
|
||||
|
|
@ -214,7 +216,9 @@ def handle_delete_prompt_confirm_notebook(prompt_name):
|
|||
new_value = available_prompts[min(current_index, len(available_prompts) - 1)]
|
||||
else:
|
||||
new_value = utils.current_time()
|
||||
Path("user_data/logs/notebook").mkdir(parents=True, exist_ok=True)
|
||||
if not Path("user_data/logs/notebook").exists():
|
||||
Path("user_data/logs/notebook").mkdir(parents=True, exist_ok=True)
|
||||
|
||||
(Path("user_data/logs/notebook") / f"{new_value}.txt").write_text("In this story,")
|
||||
available_prompts = [new_value]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue