Fix update checker: find git despite systemd minimal PATH

shutil.which("git") fails under systemd's stripped PATH. Added
_find_git() that checks common locations (/usr/bin/git, etc.)
as fallback. Also added null-safe check on apiFetch response
in the update checker frontend code.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
roberts 2026-03-14 21:48:34 -05:00
parent 68fe9b4435
commit eb1aa9d434
2 changed files with 15 additions and 2 deletions

View file

@ -16,7 +16,20 @@ router = APIRouter(prefix="/api/updates", tags=["updates"])
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
_IS_GIT = (BASE_DIR / ".git").is_dir() _IS_GIT = (BASE_DIR / ".git").is_dir()
_HAS_GIT = bool(shutil.which("git"))
def _find_git() -> bool:
"""Check if git is available, even with systemd's minimal PATH."""
if shutil.which("git"):
return True
# systemd services often have a stripped PATH — check common locations
for p in ("/usr/bin/git", "/usr/local/bin/git", "/bin/git"):
if os.path.isfile(p) and os.access(p, os.X_OK):
return True
return False
_HAS_GIT = _find_git()
def _require_git(): def _require_git():

View file

@ -397,7 +397,7 @@
if (updateDismissed) return; if (updateDismissed) return;
try { try {
const res = await Atlus.apiFetch('/api/updates/check'); const res = await Atlus.apiFetch('/api/updates/check');
if (!res.ok) return; if (!res || !res.ok) return;
const data = await res.json(); const data = await res.json();
const panel = $('#panelUpdates'); const panel = $('#panelUpdates');
if (!panel) return; if (!panel) return;