From 44f31731af75eae977cb098de070a62c0e362156 Mon Sep 17 00:00:00 2001 From: jllllll <3887729+jllllll@users.noreply.github.com> Date: Sat, 5 Aug 2023 11:47:16 -0500 Subject: [PATCH] Create logs dir if missing when saving history (#3462) --- modules/chat.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/chat.py b/modules/chat.py index 5e4eb245..8e562b98 100644 --- a/modules/chat.py +++ b/modules/chat.py @@ -394,6 +394,8 @@ def redraw_html(history, name1, name2, mode, style, reset_cache=False): def save_history(history, path=None): p = path or Path('logs/exported_history.json') + if not p.parent.is_dir(): + p.parent.mkdir(parents=True) with open(p, 'w', encoding='utf-8') as f: f.write(json.dumps(history, indent=4))