fix(stores): leave updates to Steam, list shared depots like the client, fewer Steam sign-ins

- A game already installed at another build is not updated in place by the
  store engine; the Steam client updates it (it also removes dropped files).
- InstalledDepots and InstallScripts of the shared redistributables app are
  kept in depot-id order, as the client writes them.
- After Steam refuses a sign-in for coming too often (RateLimitExceeded or
  AccountLoginDeniedThrottle) the store waits 30 minutes before trying again.
- The store's Steam sign-in is dropped when a session starts, so it never
  overlaps the Steam client's own.
This commit is contained in:
The412Banner authored and Kurt Himebauch committed 2026-11-26 08:08:03 -05:00
1 parent e2e5ac0d0a
commit a29ffaa9a8
5 files changed
+33 -4

No files matched your search

@@ -848,6 +848,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
finish()
return
}
if (savedInstanceState == null && !SessionState.running) {
// The Steam client signs in itself; the store's own sign-in must not overlap it.
Thread({ com.droiddeck.launcher.stores.steam.SteamEngine.forget() }, "steam-store-signout").start()
}
if (!SessionState.running && SessionState.phase in setOf(SessionPhase.IDLE, SessionPhase.FAILED)) {
val mode = intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM
SessionState.programArgs = intent.getStringArrayExtra(SessionService.EXTRA_PROGRAM_ARGS)?.toList().orEmpty()
@@ -15,6 +15,8 @@ internal object SteamEngine {
const val MISSING_TEXT = "Steam: the store engine is not available"
private const val RETRY_MS = 60_000L
/** After Steam refuses sign-ins for coming too often, wait well past its limit. */
private const val THROTTLED_MS = 30 * 60_000L
private val lock = Any()
@Volatile private var signedIn = false
@@ -40,7 +42,7 @@ internal object SteamEngine {
fun signIn(context: Context): JSONObject {
synchronized(lock) {
if (signedIn) return JSONObject().put("ok", true)
failed?.takeIf { SystemClock.elapsedRealtime() - failedAt < RETRY_MS }?.let { return it }
failed?.takeIf { SystemClock.elapsedRealtime() - failedAt < waitAfter(it) }?.let { return it }
val roots = JSONArray()
.put(SessionPrefs.steamRoot(context, "arm64").absolutePath)
.put(SessionPrefs.steamRoot(context, SteamClient.X86_64).absolutePath)
@@ -54,6 +56,11 @@ internal object SteamEngine {
}
}
private fun waitAfter(failure: JSONObject): Long {
val error = failure.optString("error")
return if ("RateLimitExceeded" in error || "Throttle" in error) THROTTLED_MS else RETRY_MS
}
fun forget() {
synchronized(lock) {
failed = null
@@ -180,6 +180,10 @@ pub fn run(
if takeover == Takeover::AlreadyInstalled {
return json!({"ok": true, "alreadyInstalled": true});
}
if takeover == Takeover::Update {
// Updates stay with the Steam client: it removes files a new build dropped.
return fail("update_in_steam");
}
if !register::library_registered(&req.steam_root, &req.game_library.guest) {
return fail("library_not_in_libraryfolders");
}
+16 -3
View File
@@ -65,14 +65,19 @@ impl LibraryRoot {
}
}
/// Orders a block's entries by numeric key (depot ids), the way the client lists them.
fn sort_by_numeric_key(node: &mut crate::steam::vdf::KVNode) {
node.children
.sort_by_key(|c| c.name.parse::<u64>().unwrap_or(u64::MAX));
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum Takeover {
/// No app manifest: a fresh install.
Fresh,
/// Fully installed at the build being installed: nothing to do.
AlreadyInstalled,
/// Fully installed at another build: files are checked and updated in place, the manifest
/// is merged.
/// Fully installed at another build: left to the Steam client, which updates it.
Update,
/// A half-finished client download was removed (its manifest, `downloading/<appid>` and
/// `temp/<appid>`).
@@ -357,10 +362,12 @@ pub fn register_shared_depot(
kv::set(&mut entry, "manifest", shared.manifest_id.to_string());
kv::set(&mut entry, "size", shared.size.to_string());
installed.children.push(entry);
sort_by_numeric_key(installed);
}
if let Some(script) = &shared.install_script {
let scripts = insert_after(&mut root, "InstallScripts", "InstalledDepots");
kv::set(scripts, &depot_key, script.as_str());
sort_by_numeric_key(scripts);
}
if root.child("UserConfig").is_none() {
kv::object_mut(&mut root, "UserConfig");
@@ -806,6 +813,12 @@ mod tests {
"\t\t\"228988\"\t\t\"_CommonRedist\\\\vcredist\\\\2019\\\\installscript.vdf\"\n"
));
assert!(text.contains("\t\t\"228988\"\n\t\t{\n\t\t\t\"manifest\"\t\t\"6645201662696499616\"\n\t\t\t\"size\"\t\t\"29212173\"\n\t\t}\n"));
// Depot entries are listed by id, as the client lists them.
let pos = |s: &str| text.find(s).unwrap();
assert!(pos("\t\t\"228988\"\n") < pos("\t\t\"228989\"\n"));
assert!(
pos("\t\t\"228988\"\t\t\"_CommonRedist") < pos("\t\t\"228989\"\t\t\"_CommonRedist")
);
// Unknown keys and order of the shared manifest are kept.
assert!(text.starts_with("\"AppState\"\n{\n\t\"appid\"\t\t\"228980\"\n"));
@@ -869,7 +882,7 @@ mod tests {
takeover(&fx.sd, 291550, 26465982).unwrap(),
Takeover::AlreadyInstalled
);
assert_eq!(takeover(&fx.sd, 291550, 1).unwrap(), Takeover::Update);
assert_eq!(takeover(&fx.sd, 291550, 1).unwrap(), Takeover::Update); // left to the client
assert!(state_is_finished(4));
assert!(!state_is_finished(6));
assert!(!state_is_finished(1));
@@ -60,6 +60,7 @@ pub fn eresult_name(eresult: i32) -> &'static str {
48 => "TryAnotherCM",
63 => "AccountLogonDenied",
84 => "RateLimitExceeded",
87 => "AccountLoginDeniedThrottle",
_ => "",
}
}