From 0cc187025fc00ecaf1532d812b46eacc86f91c22 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Tue, 3 Nov 2026 14:54:33 -0500 Subject: [PATCH] fix: read installed depots from completed manifest names too --- .../droiddeck/launcher/session/SteamLibraries.kt | 5 ++++- .../launcher/session/SteamLibrariesTest.kt | 9 +++++++-- docs/development/steam-game-imports.md | 3 ++- .../overlay/usr/local/bin/droiddeck-steam-games | 16 ++++++++++++++++ tools/tests/test_steam_games.py | 14 ++++++++++++++ 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamLibraries.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamLibraries.kt index 789e4a2fc1..6f89079677 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SteamLibraries.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamLibraries.kt @@ -137,10 +137,13 @@ object SteamLibraries { val managed = AddedGames.steamInstallDirs(common) return common.listFiles { f -> f.isDirectory && f.name.lowercase() !in managed && - File(f, ".download_complete").isFile && File(f, ".DepotDownloader/depot.config").isFile + File(f, ".download_complete").isFile && depotRecord(File(f, ".DepotDownloader")) }.orEmpty().sortedBy { it.name.lowercase() } } + private fun depotRecord(dir: File): Boolean = File(dir, "depot.config").isFile || + File(dir, "completed").list()?.any { it.matches(Regex("\\d+_\\d+\\.manifest")) } == true + fun rename(context: Context, id: String, label: String) { val name = clean(label).takeIf { it.isNotEmpty() } ?: return synchronized(lock) { save(context, list(context).map { if (it.id == id) Entry(it.id, it.path, name) else it }) } diff --git a/app/src/test/java/com/droiddeck/launcher/session/SteamLibrariesTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SteamLibrariesTest.kt index ef8cb3e91f..5a3fdb26c8 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/SteamLibrariesTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/SteamLibrariesTest.kt @@ -104,8 +104,13 @@ class SteamLibrariesTest { depotInstall(common, "Partial", complete = false) depotInstall(common, "Managed") File(steam, "steamapps/appmanifest_42.acf").writeText("\"AppState\"\n{\n\t\"installdir\"\t\t\"Managed\"\n}\n") - assertEquals(listOf(done), SteamLibraries.depotInstalls(common)) - assertEquals(2, SteamLibraries.gameCount(steam)) + val migrated = File(common, "Migrated").apply { + File(this, ".DepotDownloader/completed").mkdirs() + File(this, ".DepotDownloader/completed/43_99.manifest").writeBytes(ByteArray(4)) + File(this, ".download_complete").writeText("") + } + assertEquals(listOf(done, migrated), SteamLibraries.depotInstalls(common)) + assertEquals(3, SteamLibraries.gameCount(steam)) assertEquals(steam, SteamLibraries.innerLibrary(steam.parentFile)) } diff --git a/docs/development/steam-game-imports.md b/docs/development/steam-game-imports.md index 571a208c1d..04065e3a55 100644 --- a/docs/development/steam-game-imports.md +++ b/docs/development/steam-game-imports.md @@ -34,7 +34,8 @@ internal Steam library and writes an installed manifest with `Universe=1` and `StateFlags=4`. Steam ignores manifests without the universe field. A manifest without installed depots makes Steam verify every file, so the importer carries the build another client recorded: WinNative's `.winnative-steam/steamapps` manifest beside the game folder, -or a completed download's `.DepotDownloader/depot.config` depot manifest IDs. Steam then +or a completed download's depot manifest IDs from `.DepotDownloader/depot.config` or, when +that file is gone, the `_.manifest` names in `.DepotDownloader/completed`. Steam then only downloads what changed since that build. Bare manifests from earlier imports are upgraded while Steam has not touched them. Without either record Steam still verifies. WinNative's manifest also identifies the folder without a store lookup. Steam updates and uninstall diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-games b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-games index 18f2b38940..edc349a904 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-games +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-games @@ -303,6 +303,8 @@ def installed_build(folder, appid, installdir): try: ids = json.loads((folder / ".DepotDownloader/depot.config").read_text())["installedManifestIDs"] depots = sorted((int(depot), int(gid)) for depot, gid in ids.items()) + except FileNotFoundError: + depots = completed_depots(folder / ".DepotDownloader/completed") except (OSError, ValueError, KeyError, TypeError, AttributeError): return None if not depots or not all(0 < depot < 0x80000000 and 0 < gid < 0x7FFFFFFFFFFFFFFF for depot, gid in depots): @@ -310,6 +312,20 @@ def installed_build(folder, appid, installdir): return "".join(f' "{depot}"\n {{\n "manifest" "{gid}"\n }}\n' for depot, gid in depots) +def completed_depots(completed): + newest = {} + try: + for manifest in completed.iterdir(): + match = re.fullmatch(r"(\d+)_(\d+)\.manifest", manifest.name) + if match and manifest.is_file(): + depot, gid, mtime = int(match[1]), int(match[2]), manifest.stat().st_mtime + if depot not in newest or mtime > newest[depot][0]: + newest[depot] = (mtime, gid) + except OSError: + return [] + return sorted((depot, gid) for depot, (_, gid) in newest.items()) + + def update_not_started(text, steamapps, appid, installdir): fields = dict(re.findall(r'^\s*"(\w+)"\s*"([^"]*)"', text, re.M)) return (fields.get("installdir") == installdir and fields.get("buildid", "0") == "0" diff --git a/tools/tests/test_steam_games.py b/tools/tests/test_steam_games.py index 491284935f..e5db51350f 100644 --- a/tools/tests/test_steam_games.py +++ b/tools/tests/test_steam_games.py @@ -247,6 +247,20 @@ class ImportsTest(unittest.TestCase): config.write_text(json.dumps({'installedManifestIDs': {'43': 0x7FFFFFFFFFFFFFFF}})) self.assertIsNone(imports.installed_build(self.folder, 42, 'DroidDeck-42')) + def test_completed_manifests_record_installed_depots(self): + completed = self.folder / '.DepotDownloader/completed' + completed.mkdir(parents=True) + (self.folder / '.download_complete').touch() + self.assertIsNone(imports.installed_build(self.folder, 42, 'DroidDeck-42')) + (completed / '43_98.manifest').write_bytes(b'old') + (completed / '43_99.manifest').write_bytes(b'new') + (completed / '44_7.manifest').write_bytes(b'x') + os.utime(completed / '43_98.manifest', (1, 1)) + text = imports.installed_build(self.folder, 42, 'DroidDeck-42') + self.assertIn('"43"\n {\n "manifest" "99"', text) + self.assertIn('"44"\n {\n "manifest" "7"', text) + self.assertNotIn('"98"', text) + def test_bare_import_manifest_gains_installed_build(self): self.snapshot() imports.route(self.steam, self.acct, [self.game])