Revert "Safer usage of mkdir across the project"

This reverts commit 0d1597616f.
This commit is contained in:
oobabooga 2025-06-17 07:11:59 -07:00
parent 0d1597616f
commit aa44e542cb
16 changed files with 206 additions and 240 deletions

View file

@ -152,9 +152,7 @@ def autosave_prompt(text, prompt_name):
"""Automatically save the text to the selected prompt file"""
if prompt_name and text.strip():
prompt_path = Path("user_data/logs/notebook") / f"{prompt_name}.txt"
if not prompt_path.parent.exists():
prompt_path.parent.mkdir(parents=True, exist_ok=True)
prompt_path.parent.mkdir(parents=True, exist_ok=True)
prompt_path.write_text(text, encoding='utf-8')
@ -207,9 +205,7 @@ def handle_new_prompt():
# Create the new prompt file
prompt_path = Path("user_data/logs/notebook") / f"{new_name}.txt"
if not prompt_path.parent.exists():
prompt_path.parent.mkdir(parents=True, exist_ok=True)
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)
@ -226,9 +222,7 @@ def handle_delete_prompt_confirm_default(prompt_name):
new_value = available_prompts[min(current_index, len(available_prompts) - 1)]
else:
new_value = utils.current_time()
if not Path("user_data/logs/notebook").exists():
Path("user_data/logs/notebook").mkdir(parents=True, exist_ok=True)
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]