Cleanup and security updates.
This commit is contained in:
@@ -6,6 +6,7 @@ import base64
|
||||
from collections import deque
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import queue
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -21,6 +22,7 @@ from .install_status import (
|
||||
PrimaryAction,
|
||||
inspect_game_installation,
|
||||
)
|
||||
from .import_state import game_import_requires_verification
|
||||
from .news import (
|
||||
Broadcast,
|
||||
NewsArticle,
|
||||
@@ -63,6 +65,34 @@ class DashboardError(RuntimeError):
|
||||
"""Raised when the native dashboard cannot be displayed."""
|
||||
|
||||
|
||||
def launcher_restart_spec(
|
||||
paths: AppPaths,
|
||||
environment: Mapping[str, str] | None = None,
|
||||
) -> tuple[list[str], dict[str, str]]:
|
||||
"""Build an isolated restart that imports the newly activated release."""
|
||||
|
||||
current = paths.launcher_current
|
||||
if not current.is_symlink():
|
||||
raise DashboardError(f"launcher current path is not a symbolic link: {current}")
|
||||
try:
|
||||
release = current.resolve(strict=True)
|
||||
except OSError as exc:
|
||||
raise DashboardError(f"launcher current release is unavailable: {exc}") from exc
|
||||
releases = paths.launcher_releases.resolve(strict=False)
|
||||
if release.parent != releases or not (release / "ptlinux").is_dir():
|
||||
raise DashboardError(f"launcher current release is outside the release store: {release}")
|
||||
env = dict(os.environ if environment is None else environment)
|
||||
env.update(
|
||||
{
|
||||
"PTLINUX_INSTALL_DIR": str(paths.data),
|
||||
"PTLINUX_APP_HOME": str(paths.app_home),
|
||||
"PYTHONSAFEPATH": "1",
|
||||
"PYTHONPATH": str(release),
|
||||
}
|
||||
)
|
||||
return [sys.executable, "-B", "-P", "-m", "ptlinux", "gui"], env
|
||||
|
||||
|
||||
class ProgressCoalescer:
|
||||
"""Keep only the latest cross-thread progress event for the Tk loop.
|
||||
|
||||
@@ -1160,7 +1190,7 @@ def run_dashboard(paths: AppPaths) -> None:
|
||||
runtime_compatibility = None
|
||||
local_status = inspect_game_installation(paths)
|
||||
refresh_primary_action(update_activity=update_activity)
|
||||
if not local_status.installed:
|
||||
if not local_status.installed or game_import_requires_verification(paths):
|
||||
return
|
||||
|
||||
def worker() -> None:
|
||||
@@ -1279,8 +1309,10 @@ def run_dashboard(paths: AppPaths) -> None:
|
||||
if value == 0:
|
||||
append_log("Launcher update activated; restarting the dashboard.")
|
||||
try:
|
||||
restart_command, restart_environment = launcher_restart_spec(paths)
|
||||
subprocess.Popen(
|
||||
command_for("gui"),
|
||||
restart_command,
|
||||
env=restart_environment,
|
||||
close_fds=True,
|
||||
start_new_session=True,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user