mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-29 06:44:00 -06:00
roster: fix overwriting old saves on Windows
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user