fix: the Steam client download resumes, retries and shows megabytes

A first run downloads the native client, about 360 MB in 17 parts, before
anything is on screen. The script ran plain `curl -fsSL` per part: no
timeout, no retry, no progress. A stalled connection could wait for ever
on "downloading Steam: bins_linuxarm64_linuxarm64 (2/17)" (a 110 MB part),
a failed one ended the session and threw away everything fetched, and
the loading screen said "~1-2 min" while counting parts, not bytes.

Parts now go to package/droiddeck-download and stay there until the client
is installed. Each one resumes from the bytes on disk (curl -C -), a
transfer under 4 KB/s for a minute is dropped and resumed, attempts
without progress back off 5-30 s before giving up, and a finished part is
marked unpacked so a later session skips it. Bytes that fail their
checksum are fetched whole again; a server that will not resume starts the
part over; parts left for another client version are dropped. A repair
redoes every part once and keeps what an interrupted repair redid.

Every 5 s the step line carries megabytes overall ("(2/17), 45 of 360
MB"), which the loading screen shows as "45 / 360 MB" with the bar
following the bytes. The session's step no longer promises 1-2 minutes.
This commit is contained in:
maxjivi05 committed 2026-10-11 14:45:57 -04:00
1 parent e5ba165027
commit 342d2e7f20
5 files changed
+311 -20

No files matched your search

@@ -0,0 +1,37 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
class LoadingStateTest {
@Test fun clientDownloadCountsMegabytesWhenTheRuntimeSaysThem() {
assertEquals(
"45 / 360 MB" to 12,
LoadingState.clientDownload("== STEP 17:38:20 downloading Steam: bins_linuxarm64_linuxarm64 (2/17), 45 of 360 MB"),
)
}
@Test fun aStalledDownloadStillShowsWhereItIs() {
assertEquals(
"45 / 360 MB" to 12,
LoadingState.clientDownload(
"== STEP 17:39:20 downloading Steam: bins_linuxarm64_linuxarm64 (2/17), 45 of 360 MB" +
" - interrupted (curl exit 28), trying again in 5 s",
),
)
}
@Test fun anOlderRuntimeShowsThePartAndItsNumber() {
assertEquals(
"bins_linuxarm64_linuxarm64" to 11,
LoadingState.clientDownload("== STEP 17:38:17 downloading Steam: bins_linuxarm64_linuxarm64 (2/17)"),
)
// Under a megabyte in all: nothing to count yet.
assertEquals("a_all" to 50, LoadingState.clientDownload("== STEP 00:00:00 downloading Steam: a_all (1/2), 0 of 0 MB"))
}
@Test fun otherStepsAreNotClientDownloads() {
assertNull(LoadingState.clientDownload("== STEP 17:38:14 checking the Steam client (a first run downloads it)"))
}
}