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
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
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))