From c5f0c60ec879ee339f6ea81a21f790a2ad27eb95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Ga=C5=A1par=C3=ADk?= Date: Thu, 7 May 2020 14:48:38 +0200 Subject: [PATCH] roster: fix overwriting old saves on Windows --- pqcli/roster.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pqcli/roster.py b/pqcli/roster.py index 1833ab5..1537909 100644 --- a/pqcli/roster.py +++ b/pqcli/roster.py @@ -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)