Create logs dir if missing when saving history (#3462)

This commit is contained in:
jllllll 2023-08-05 11:47:16 -05:00 committed by GitHub
parent 5ee95d126c
commit 44f31731af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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))