roster: fix overwriting old saves on Windows

This commit is contained in:
Petr Gašparík
2020-05-07 15:27:56 +02:00
committed by rr-
parent fc4dcff9e3
commit c5f0c60ec8
+3
View File
@@ -1,3 +1,4 @@
import os
import logging
import pickle
import typing as T
@@ -29,6 +30,8 @@ class Roster:
tmp_path.parent.mkdir(parents=True, exist_ok=True)
tmp_path.write_bytes(pickle.dumps(self.players))
if self.path.exists():
if old_path.exists():
old_path.unlink()
self.path.rename(old_path)
tmp_path.rename(self.path)