From cacd14bee89d1c1ff00fb11ebd2c68b407c90f1f Mon Sep 17 00:00:00 2001 From: cryzed Date: Sun, 11 Sep 2022 20:17:09 +0200 Subject: [PATCH] Only create backup if path exists --- modules/styles.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/styles.py b/modules/styles.py index 25ec504b..bc7f070f 100644 --- a/modules/styles.py +++ b/modules/styles.py @@ -63,5 +63,6 @@ def save_styles(path: str, styles: abc.Iterable[PromptStyle]) -> None: writer.writerows(style._asdict() for style in styles) # Always keep a backup file around - shutil.copy(path, path + ".bak") + if os.path.exists(path): + shutil.move(path, path + ".bak") shutil.move(temp_path, path)