Skip to content

Commit d6ac731

Browse files
committed
local settings save location fix
1 parent 6277528 commit d6ac731

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

server/runs.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
from pathlib import Path
1212

1313
RUNS_SUBCOLLECTION = "runs"
14-
LOCAL_RUNS_PATH = Path(__file__).resolve().parent.parent / "runs.json"
14+
15+
import sys
16+
if getattr(sys, "frozen", False):
17+
_app_support = Path.home() / "Library" / "Application Support" / "Petey"
18+
_app_support.mkdir(parents=True, exist_ok=True)
19+
LOCAL_RUNS_PATH = _app_support / "runs.json"
20+
else:
21+
LOCAL_RUNS_PATH = Path(__file__).resolve().parent.parent / "runs.json"
1522

1623

1724
def _use_local() -> bool:

server/settings.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919
firestore = None
2020

2121
BASE_DIR = Path(__file__).resolve().parent.parent
22-
SETTINGS_PATH = BASE_DIR / "settings.json"
22+
23+
# When running as a frozen app (.app bundle), the bundle is read-only.
24+
# Store settings in ~/Library/Application Support/Petey/ instead.
25+
import sys
26+
if getattr(sys, "frozen", False):
27+
_app_support = Path.home() / "Library" / "Application Support" / "Petey"
28+
_app_support.mkdir(parents=True, exist_ok=True)
29+
SETTINGS_PATH = _app_support / "settings.json"
30+
else:
31+
SETTINGS_PATH = BASE_DIR / "settings.json"
2332
COLLECTION = "user_settings"
2433

2534
DEFAULTS = {

0 commit comments

Comments
 (0)