Only create backup if path exists

This commit is contained in:
cryzed 2022-09-11 20:17:09 +02:00 committed by AUTOMATIC1111
parent 5fbed65236
commit cacd14bee8
1 changed files with 2 additions and 1 deletions

View File

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