fix: extract GOG installers natively on ARM

The GOG installer fallback downloaded only the setup stub and then launched it through Proton/FEX, where the 32-bit Inno Setup stub corrupts its own path strings before CreateFileW. Download every installer part and extract them with the bundled ARM64 innoextract in the Linux guest instead, registering the real game executable. Also classify truncated response bodies as server faults so the native engine retries on the other CDN mirror.
This commit is contained in:
Moroni Granja committed 2026-10-20 08:09:20 -03:00
1 parent a5c587bd71
commit b9d703db34
17 files changed
+435 -65

No files matched your search

@@ -0,0 +1,90 @@
package com.droiddeck.launcher.stores.gog
import java.io.File
import java.io.IOException
import java.nio.file.Files
import org.json.JSONObject
import org.junit.Assert.assertEquals
import org.junit.Assert.assertThrows
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [33])
class GogInstallerPartsTest {
private fun downloads(json: String) = JSONObject("""{"downloads":$json}""").getJSONObject("downloads")
@Test fun everyFileOfTheWindowsInstallerIsKeptAndThePartsAreNamedAfterItsSetup() {
val parts = GogDownloadManager.installerParts(
downloads(
"""{"installers":[
{"os":"windows","language":"en","files":[
{"id":"en1installer0","size":1048576,"downlink":"https://api.gog.com/products/1947927225/downlink/installer/en1installer0"},
{"id":"en1installer1","size":3786407936,"downlink":"https://api.gog.com/products/1947927225/downlink/installer/en1installer1"}
]},
{"os":"linux","files":[{"downlink":"https://example.invalid/linux"}]}
]}""",
),
"1947927225",
)
assertEquals(listOf("setup_1947927225.exe", "setup_1947927225-1.bin"), parts.map { it.filename })
assertEquals(listOf(1048576L, 3786407936L), parts.map { it.size })
assertTrue(parts[1].url.endsWith("en1installer1"))
}
@Test fun explicitNamesAreKeptAndUnnamedPartsFollowTheFirstSetupExe() {
val parts = GogDownloadManager.installerParts(
downloads(
"""{"installers":[{"os":"windows","files":[
{"filename":"setup_witcher_2.1.0.exe","downlink":"https://example.invalid/setup"},
{"downlink":"https://example.invalid/data"},
{"filename":"readme.bin","downlink":"https://example.invalid/readme"}
]}]}""",
),
"1207658924",
)
assertEquals(listOf("setup_witcher_2.1.0.exe", "setup_witcher_2.1.0-1.bin", "readme.bin"), parts.map { it.filename })
}
@Test fun aSingleManualInstallerIsNamedForTheGameAndSanitised() {
val parts = GogDownloadManager.installerParts(
downloads("""{"installers":[{"os":"windows","manualUrl":"https://example.invalid/setup","total_size":42}]}"""),
"../game id",
)
assertEquals(1, parts.size)
assertEquals("setup_.._game_id.exe", parts[0].filename)
assertEquals(42L, parts[0].size)
}
@Test fun installerPartsStayInsideTheGameFolder() {
val root = kotlin.io.path.createTempDirectory("gog-installer").toFile()
try {
assertEquals(
File(root, "setup_1.exe").canonicalFile,
GogDownloadManager.installerDestination(root, "setup_1.exe"),
)
assertThrows(IOException::class.java) {
GogDownloadManager.installerDestination(root, "../outside.exe")
}
val outside = File(root.parentFile, "outside-${System.nanoTime()}.bin").apply { writeText("x") }
try {
Files.createSymbolicLink(File(root, "setup_1-1.bin").toPath(), outside.toPath())
assertThrows(IOException::class.java) {
GogDownloadManager.installerDestination(root, "setup_1-1.bin")
}
} finally {
outside.delete()
}
} finally {
root.deleteRecursively()
}
}
@Test fun anotherPlatformOrNoDownloadsAddsNothing() {
assertEquals(0, GogDownloadManager.installerParts(downloads("""{"installers":[{"os":"linux","manualUrl":"https://example.invalid/x"}]}"""), "1").size)
assertEquals(0, GogDownloadManager.installerParts(downloads("{}"), "1").size)
}
}