mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
fix: stop importing games as Spacewar (480) and follow a changed Steam app id (#1896)
This commit is contained in:
1 parent
88719f25d2
commit
583f34fc55
9 files changed
+303
-26
No files matched your search
@@ -20,6 +20,7 @@ LIBRARY = "/mnt/droiddeck-sd"
|
||||
LEGACY_LIBRARY = "/mnt/bannerlator-sd"
|
||||
PARKED = ".droiddeck-parked"
|
||||
BASE_ID = 76561197960265728
|
||||
SPACEWAR = 480
|
||||
|
||||
|
||||
def read_json(path, default):
|
||||
@@ -86,14 +87,14 @@ def identify(game):
|
||||
folder = Path(game["folder"])
|
||||
steamapps = folder.parent.parent
|
||||
for library in ([steamapps] if folder.parent.name == "common" and steamapps.name == "steamapps" else []) + [folder.parent / WINNATIVE]:
|
||||
matches = manifest_ids(library, folder.name)
|
||||
matches = [appid for appid in manifest_ids(library, folder.name) if appid != SPACEWAR]
|
||||
if matches:
|
||||
return matches[0] if len(matches) == 1 else None
|
||||
ids = set()
|
||||
for parent in {folder, Path(game["exe"]).parent}:
|
||||
try:
|
||||
appid = int((parent / "steam_appid.txt").read_text().strip())
|
||||
if 0 < appid < 0x80000000:
|
||||
if 0 < appid < 0x80000000 and appid != SPACEWAR:
|
||||
ids.add(appid)
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
@@ -107,7 +108,7 @@ def identify(game):
|
||||
ids = {int(item["id"]) for item in items
|
||||
if key(item.get("name", "")) == key(game["name"]) and key(game["name"])}
|
||||
if ids:
|
||||
return next(iter(ids)) if len(ids) == 1 else None
|
||||
return next(iter(ids)) if len(ids) == 1 and SPACEWAR not in ids else None
|
||||
return None
|
||||
except (OSError, ValueError, KeyError):
|
||||
return None
|
||||
@@ -423,20 +424,20 @@ def seed_install(steam_root, game, appid):
|
||||
return True
|
||||
|
||||
|
||||
def release(steam_root, game):
|
||||
"""Undoes an import made before store games were skipped. Only our symlink and manifest go;
|
||||
the store's folder stays where it is."""
|
||||
def release(steam_root, game, stale, reason):
|
||||
"""Undoes the imports of the game's folder as the Steam apps [stale] picks. Only our symlink and
|
||||
manifest go; the folder stays where it is."""
|
||||
steamapps = Path(steam_root) / "steamapps"
|
||||
sources = {game.get("folder", ""), legacy_path(game.get("folder", ""))}
|
||||
for target in sorted((steamapps / "common").glob("DroidDeck-*")):
|
||||
appid = target.name.removeprefix("DroidDeck-")
|
||||
if not (appid.isdigit() and target.is_symlink() and os.readlink(target) in sources):
|
||||
if not (appid.isdigit() and target.is_symlink() and os.readlink(target) in sources and stale(int(appid))):
|
||||
continue
|
||||
for manifest in (steamapps / f"appmanifest_{appid}.acf", steamapps / PARKED / f"appmanifest_{appid}.acf"):
|
||||
if manifest.is_file() and ours(manifest, appid):
|
||||
manifest.unlink()
|
||||
target.unlink()
|
||||
print(f"droiddeck-steam-games: {game.get('name', appid)} came from {game['store']}; it is a shortcut again, not Steam app {appid}")
|
||||
print(f"droiddeck-steam-games: {game.get('name', appid)} {reason}; it is no longer Steam app {appid}")
|
||||
|
||||
|
||||
def route(steam_root, acct, games):
|
||||
@@ -457,7 +458,7 @@ def route(steam_root, acct, games):
|
||||
for game in games:
|
||||
if store_game(game):
|
||||
try:
|
||||
release(steam_root, game)
|
||||
release(steam_root, game, lambda old: True, f"came from {game['store']}")
|
||||
except OSError as error:
|
||||
print(f"droiddeck-steam-games: store import not undone ({error})")
|
||||
shortcuts.append(game)
|
||||
@@ -469,9 +470,14 @@ def route(steam_root, acct, games):
|
||||
appid = candidates.get(folder, candidates.get(legacy_path(folder)))
|
||||
stamp = source_stamp(game)
|
||||
recorded = sources.get(folder, sources.get(legacy_path(folder)))
|
||||
confirmed = (isinstance(appid, int) and 0 < appid < 0x80000000
|
||||
and owned.get(str(appid)) is True and stamp is not None
|
||||
and recorded in (stamp, [stamp[0], legacy_path(stamp[1])] + stamp[2:]))
|
||||
current = stamp is not None and recorded in (stamp, [stamp[0], legacy_path(stamp[1])] + stamp[2:])
|
||||
named = isinstance(appid, int) and 0 < appid < 0x80000000 and appid != SPACEWAR
|
||||
try:
|
||||
release(steam_root, game, lambda old: old == SPACEWAR or (current and named and old != appid),
|
||||
"names another Steam app now")
|
||||
except OSError as error:
|
||||
print(f"droiddeck-steam-games: earlier import not undone ({error})")
|
||||
confirmed = named and current and owned.get(str(appid)) is True
|
||||
if confirmed:
|
||||
try:
|
||||
if seed_install(steam_root, game, appid):
|
||||
@@ -480,7 +486,7 @@ def route(steam_root, acct, games):
|
||||
print(f"droiddeck-steam-games: {game.get('name', appid)} stays a shortcut this session: it could not be linked as Steam app {appid}")
|
||||
except OSError as error:
|
||||
print(f"droiddeck-steam-games: import unavailable ({error})")
|
||||
elif isinstance(appid, int) and 0 < appid < 0x80000000 and seeded(steamapps, game, appid):
|
||||
elif named and seeded(steamapps, game, appid):
|
||||
routes[str(game["appid"])] = appid
|
||||
continue
|
||||
shortcuts.append(game)
|
||||
|
||||
Reference in new issue
Block a user