Refactor radar system
This commit is contained in:
@@ -7,6 +7,7 @@ import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from python_app.file_io import atomic_write_json
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -37,7 +38,7 @@ class GuiSessionStateStore:
|
||||
|
||||
try:
|
||||
payload = json.loads(self._path.read_text(encoding="utf-8"))
|
||||
except (OSError, json.JSONDecodeError) as exc:
|
||||
except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
||||
# The state file is GUI-local cache — a corrupted file should not
|
||||
# prevent the app from starting. Reset to defaults and let the
|
||||
# next write overwrite it.
|
||||
@@ -55,11 +56,6 @@ class GuiSessionStateStore:
|
||||
|
||||
def write(self, state: GuiSessionState) -> Path:
|
||||
"""Atomically write session-state JSON file."""
|
||||
temp_path = self._path.with_suffix(self._path.suffix + ".tmp")
|
||||
temp_path.write_text(
|
||||
json.dumps({"last_profile_path": state.last_profile_path}, indent=2),
|
||||
encoding="utf-8",
|
||||
)
|
||||
temp_path.replace(self._path)
|
||||
atomic_write_json(self._path, {"last_profile_path": state.last_profile_path}, durable=True)
|
||||
logger.debug("Wrote GUI session-state to %s", self._path)
|
||||
return self._path
|
||||
|
||||
Reference in New Issue
Block a user