mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 15:56:01 +00:00
perf(steam): setup applies Steam's client update so the first launch has nothing to unpack (#3152)
* perf(steam): setup applies Steam's client update itself so the first launch has nothing to unpack The setup already downloads every package of Steam's client update. droiddeck-steam-preapply now extracts them and writes the .installed and .manifest records the way Steam's updater does, so the first launch verifies and starts instead of unpacking for about half a minute and restarting. When it cannot, the packages stay and Steam updates itself as before. * perf(setup): the Steam stage skips the plain packages it just applied, and Proton's install trusts the prefetch's checksum With the whole client update applied from the cached packages, the separate 362 MB plain-package install is redundant: the cache pass applies the update and finishes the install, and the plain install stays as the fallback. DroidDeck Proton's archive was hashed twice more at install time after the prefetch had already verified it; the install now reuses that result while the file is unchanged. * fix(steam): a failed or cancelled apply leaves nothing stale, extraction stays inside the Steam root, and a cache failure still installs A failed apply removes its record and the cache marker so the next run retries; cancelling stops the helper; entries that leave the Steam root, directly or through a symlink, are refused; the plain install still runs when the cache pass fails; Proton's install reuses the prefetch's verification only for the same digest. * fix(steam): a cancelled apply clears the cache marker too
This commit is contained in:
1 parent
9db80cebd9
commit
2e3b69e9ff
7 files changed
+369
-8
No files matched your search
@@ -25,6 +25,10 @@ object ProtonExtras {
|
||||
var installInProgress = false
|
||||
@Volatile var prefetching = false
|
||||
private set
|
||||
@Volatile private var checkedArchive: Triple<String, Long, Long>? = null
|
||||
@Volatile private var checkedDigest: String? = null
|
||||
|
||||
private fun fingerprint(archive: File) = Triple(archive.path, archive.length(), archive.lastModified())
|
||||
@Volatile
|
||||
private var replacing = false
|
||||
|
||||
@@ -259,7 +263,10 @@ object ProtonExtras {
|
||||
if (asset.size > 0 && archive.length() > asset.size) archive.delete()
|
||||
val missing = (asset.size - archive.length()).coerceAtLeast(0L)
|
||||
if (StatFs(context.filesDir.path).availableBytes < NEED_BYTES + missing) return context.getString(R.string.pextra_no_space, tool.name)
|
||||
return fetchArchive(context, tool, asset, archive, onProgress)
|
||||
val problem = fetchArchive(context, tool, asset, archive, onProgress)
|
||||
checkedArchive = if (problem == null && asset.sha256 != null && asset.size > 0 && archive.length() == asset.size) fingerprint(archive) else null
|
||||
checkedDigest = if (checkedArchive != null) asset.sha256 else null
|
||||
return problem
|
||||
}
|
||||
|
||||
private fun installNow(context: Context, tool: Tool, onProgress: (String, Int) -> Unit): String? {
|
||||
@@ -275,7 +282,9 @@ object ProtonExtras {
|
||||
return context.getString(R.string.pextra_no_space, tool.name)
|
||||
}
|
||||
|
||||
fetchArchive(context, tool, asset, archive, onProgress)?.let { return it }
|
||||
val checked = asset.sha256 != null && asset.size > 0 && checkedArchive == fingerprint(archive) &&
|
||||
checkedDigest.equals(asset.sha256, ignoreCase = true)
|
||||
if (!checked) fetchArchive(context, tool, asset, archive, onProgress)?.let { return it }
|
||||
if (asset.size > 0 && archive.length() != asset.size) {
|
||||
if (archive.length() > asset.size) {
|
||||
archive.delete()
|
||||
@@ -286,6 +295,7 @@ object ProtonExtras {
|
||||
|
||||
onProgress(context.getString(R.string.pextra_verifying), -1)
|
||||
val verified = when {
|
||||
checked -> true
|
||||
asset.sha256 != null -> asset.sha256.equals(Hashes.sha256(archive), ignoreCase = true)
|
||||
asset.sha512 != null -> {
|
||||
val expected = Downloader.downloadDirect(asset.sha512)?.let { Regex("(?i)\\b[0-9a-f]{128}\\b").find(it)?.value }
|
||||
|
||||
@@ -130,6 +130,7 @@ object SessionFiles {
|
||||
"usr/local/bin/droiddeck-desktop-clipboard" to "usr/local/bin/droiddeck-desktop-clipboard",
|
||||
"usr/local/bin/droiddeck-gpu-window" to "usr/local/bin/droiddeck-gpu-window",
|
||||
"usr/local/bin/droiddeck-steam-install" to "usr/local/bin/droiddeck-steam-install",
|
||||
"usr/local/bin/droiddeck-steam-preapply" to "usr/local/bin/droiddeck-steam-preapply",
|
||||
"usr/local/bin/droiddeck-steam-ui-scale" to "usr/local/bin/droiddeck-steam-ui-scale",
|
||||
"usr/local/bin/droiddeck-steam-language" to "usr/local/bin/droiddeck-steam-language",
|
||||
"usr/local/bin/droiddeck-steam-shaders" to "usr/local/bin/droiddeck-steam-shaders",
|
||||
|
||||
@@ -71,11 +71,9 @@ object SteamClientPrefetch {
|
||||
LinuxRuntime.writeAccounts(context)
|
||||
SessionFiles.stage(context, root)
|
||||
val install = installPending(context)
|
||||
if (install) {
|
||||
val problem = script(context, emptyList(), label, 0, 35)
|
||||
if (problem != null) return problem
|
||||
}
|
||||
return script(context, listOf("--cache"), label, if (install) 35 else 0, 100)
|
||||
val cacheProblem = script(context, listOf("--cache"), label, 0, if (install) 90 else 100)
|
||||
if (cacheProblem == CANCELLED || !install) return cacheProblem
|
||||
return script(context, emptyList(), label, 90, 100)
|
||||
}
|
||||
|
||||
private fun script(context: Context, args: List<String>, label: (Int) -> String, from: Int, to: Int): String? {
|
||||
|
||||
Reference in new issue
Block a user