瀏覽代碼

Only create backup if path exists

cryzed 2 年之前
父節點
當前提交
cacd14bee8
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      modules/styles.py

+ 2 - 1
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)