mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-11-23 10:06:18 +01:00
The KCD2 run reported success but Steam re-downloaded 90 GB anyway. Two
independent causes, plus a defect that hid both.
force_install_dir sets a Steam *library root*, not an install directory.
Pointing it at the game folder made steamcmd search <game>/steamapps/ for
manifests ("Loaded 0 apps from install folder"), create that stray dir, and
fail the app with "Invalid platform" for lack of depot context. Dropped it;
the app already lives in a registered library. Separately, a Linux steamcmd
needs +@sSteamCmdForcePlatformType windows for a Windows-only title.
Steam then discarded the manifest because it was self-contradictory:
StateFlags=4 while BytesDownloaded (22 GB) != BytesToDownload (92 GB), with
tens of GB still staged under steamapps/downloading/. Across every genuinely
installed manifest the byte counters are equal in pairs, StagingSize is 0 and
staging is empty; DownloadType is kept, not dropped. Settle all of it, and
refuse to call an install real until it holds.
The defect that hid this: steamcmd exited 8 having done nothing and the tool
still wrote StateFlags=4, printed a success line and returned 0. Now gated on
depotdownloader succeeding, every required depot being cached, real game
content on disk, a matching buildid and no running Steam client -- and it
re-reads the manifest after writing.
Also fixes data corruption found in review: vdf.dumps never re-escaped
backslashes, so each parse/dump cycle halved them and silently mangled the
Windows paths in appmanifest_228980.acf's InstallScripts. Manifest writes are
now atomic with a preserved pristine .acf.bak.
Adds per-run logging to ~/.local/state/steam-game-installer (argv, exit codes,
full subprocess output, manifest before/after), teed through a pty so
steamcmd's password prompt still works.
Verified end-to-end on KCD2: Steam logged "Fully Installed, App Running" and
the game launched with no download queued. Coverage 100% statements+branches,
enforced by fail_under.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EK4urCmbTqN4Vrc3nGBcXF
81 lines
2.2 KiB
Python
81 lines
2.2 KiB
Python
import logging
|
|
|
|
from steam_installer import depotdl
|
|
|
|
|
|
def _capture(monkeypatch):
|
|
"""Intercept the subprocess call and hand back the argv it was given."""
|
|
seen = {}
|
|
|
|
def fake_run_logged(cmd, logger, timeout=None):
|
|
seen["cmd"] = cmd
|
|
return seen.get("rc", 0), ""
|
|
|
|
monkeypatch.setattr(depotdl.runlog, "run_logged", fake_run_logged)
|
|
return seen
|
|
|
|
|
|
def test_download_builds_expected_argv(tmp_path, monkeypatch):
|
|
seen = _capture(monkeypatch)
|
|
|
|
depotdl.download(
|
|
appid=1771300,
|
|
install_dir=tmp_path / "Game",
|
|
username="krzys2000",
|
|
logger=logging.getLogger("t"),
|
|
language="english",
|
|
max_downloads=32,
|
|
)
|
|
|
|
cmd = seen["cmd"]
|
|
assert cmd[0] == "depotdownloader"
|
|
pairs = dict(zip(cmd[1::2], cmd[2::2]))
|
|
assert pairs["-app"] == "1771300"
|
|
assert pairs["-language"] == "english"
|
|
assert pairs["-max-downloads"] == "32"
|
|
assert pairs["-username"] == "krzys2000"
|
|
|
|
|
|
def test_download_always_passes_os_windows(tmp_path, monkeypatch):
|
|
"""Without -os, depotdownloader defaults to the host OS and can filter out
|
|
every real (Windows-tagged) depot -- the original "0 bytes from 0 depots"."""
|
|
seen = _capture(monkeypatch)
|
|
|
|
depotdl.download(
|
|
appid=1771300,
|
|
install_dir=tmp_path / "Game",
|
|
username="u",
|
|
logger=logging.getLogger("t"),
|
|
)
|
|
|
|
cmd = seen["cmd"]
|
|
assert cmd[cmd.index("-os") + 1] == "windows"
|
|
assert "-remember-password" in cmd
|
|
|
|
|
|
def test_download_creates_the_install_dir(tmp_path, monkeypatch):
|
|
_capture(monkeypatch)
|
|
target = tmp_path / "nested" / "Game"
|
|
|
|
depotdl.download(
|
|
appid=1, install_dir=target, username="u", logger=logging.getLogger("t")
|
|
)
|
|
|
|
assert target.is_dir()
|
|
|
|
|
|
def test_download_returns_the_exit_code_instead_of_raising(tmp_path, monkeypatch):
|
|
"""The caller must distinguish "download failed" from "manifest step failed"
|
|
to decide whether touching the manifest is safe at all."""
|
|
seen = _capture(monkeypatch)
|
|
seen["rc"] = 1
|
|
|
|
returncode = depotdl.download(
|
|
appid=1,
|
|
install_dir=tmp_path / "Game",
|
|
username="u",
|
|
logger=logging.getLogger("t"),
|
|
)
|
|
|
|
assert returncode == 1
|