Dark theme, scan auto-ingest, packaging prep, and README refresh
This commit is contained in:
+28
-3
@@ -1,8 +1,20 @@
|
||||
"""Central configuration, driven by environment variables."""
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
||||
# PyInstaller sets ``sys.frozen`` and unpacks bundled files to ``sys._MEIPASS``.
|
||||
# Read-only resources (DATs, loader, icons) then live in the bundle; otherwise
|
||||
# they live in the project checkout.
|
||||
IS_FROZEN = getattr(sys, "frozen", False)
|
||||
_BUNDLE_DIR = getattr(sys, "_MEIPASS", None)
|
||||
|
||||
PROJECT_ROOT = Path(_BUNDLE_DIR).resolve() if _BUNDLE_DIR else Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
def resource_path(*parts):
|
||||
"""Absolute path to a read-only bundled resource (works when frozen)."""
|
||||
return PROJECT_ROOT.joinpath(*parts)
|
||||
|
||||
DATA_DIR = Path(os.environ.get("PSP_DATA_DIR", str(PROJECT_ROOT / "data")))
|
||||
DATS_DIR = Path(os.environ.get("PSP_DATS_DIR", str(DATA_DIR / "dats")))
|
||||
@@ -12,9 +24,12 @@ def _default_state_dir():
|
||||
"""Local state directory (fast, reliable local disk).
|
||||
|
||||
SQLite locking is unreliable over network filesystems (SMB/FUSE), so the
|
||||
library DB and the cover cache live on local storage while DATs, manual
|
||||
covers and credentials stay in ``DATA_DIR`` (which may be a network share).
|
||||
library DB and the cover cache live on local storage while read-only DATs
|
||||
stay bundled with the app.
|
||||
"""
|
||||
if os.name == "nt":
|
||||
base = os.environ.get("LOCALAPPDATA") or os.environ.get("APPDATA") or str(Path.home())
|
||||
return Path(base) / "PSPPreserve"
|
||||
xdg = os.environ.get("XDG_STATE_HOME")
|
||||
base = Path(xdg) if xdg else Path.home() / ".local" / "state"
|
||||
return base / "psp-preserve"
|
||||
@@ -23,9 +38,19 @@ def _default_state_dir():
|
||||
STATE_DIR = Path(os.environ.get("PSP_STATE_DIR", str(_default_state_dir())))
|
||||
DB_PATH = Path(os.environ.get("PSP_DB_PATH", str(STATE_DIR / "library.sqlite")))
|
||||
COVERS_DIR = Path(os.environ.get("PSP_COVERS_DIR", str(STATE_DIR / "covers")))
|
||||
# User-writable data (credentials, manual covers, PS1 templates, NPS TSV cache).
|
||||
# In dev this is the checkout's ``data/``; when frozen the bundle is read-only,
|
||||
# so it points at local state that survives app upgrades.
|
||||
USER_DATA_DIR = Path(os.environ.get(
|
||||
"PSP_USER_DATA_DIR", str(DATA_DIR if not IS_FROZEN else STATE_DIR / "data")))
|
||||
LEGACY_DB_PATH = DATA_DIR / "library.sqlite"
|
||||
LEGACY_COVERS_DIR = DATA_DIR / "covers"
|
||||
|
||||
|
||||
def user_data_path(*parts):
|
||||
"""Absolute path to a user-writable data file/folder (works when frozen)."""
|
||||
return USER_DATA_DIR.joinpath(*parts)
|
||||
|
||||
# Redump 7z store (browsable in the Store tab). Env override; GUI setting wins.
|
||||
STORE_ROOT = Path(os.environ.get("PSP_STORE_DIR", "/media/downloads/Sony - PlayStation Portable"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user