mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix: a failed Steam client download ends the session with a message instead of silently (#997)
This commit is contained in:
1 parent
152b961940
commit
abeaf7ccb6
38 files changed
+267
-9
No files matched your search
@@ -1879,17 +1879,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
var enosys = 0
|
||||
var fexMissing = false
|
||||
val size = log.length()
|
||||
java.io.RandomAccessFile(log, "r").use { f ->
|
||||
val text = java.io.RandomAccessFile(log, "r").use { f ->
|
||||
val start = maxOf(0L, size - 512L * 1024)
|
||||
f.seek(start)
|
||||
val bytes = ByteArray((size - start).toInt())
|
||||
f.readFully(bytes)
|
||||
String(bytes, Charsets.ISO_8859_1).lineSequence().forEach { line ->
|
||||
if (line.contains("Function not implemented")) enosys++
|
||||
if (line.contains(FEX_MISSING)) fexMissing = true
|
||||
}
|
||||
String(bytes, Charsets.ISO_8859_1)
|
||||
}
|
||||
if (fexMissing) {
|
||||
text.lineSequence().forEach { line ->
|
||||
if (line.contains("Function not implemented")) enosys++
|
||||
if (line.contains(FEX_MISSING)) fexMissing = true
|
||||
}
|
||||
val steamSetup = com.droiddeck.launcher.session.SteamClientSetupFailure.find(text.lineSequence())
|
||||
if (steamSetup != null) {
|
||||
val message = getString(if (steamSetup.download) R.string.session_end_steam_download else R.string.session_end_steam_setup)
|
||||
EndHint(listOfNotNull(message, steamSetup.curlError).joinToString("\n"))
|
||||
} else if (fexMissing) {
|
||||
val what = com.droiddeck.launcher.frontend.Library.nameForProgram(SessionState.program) ?: getString(R.string.session_end_program)
|
||||
EndHint(getString(R.string.session_end_fex_missing, what), evenOnSuccess = true)
|
||||
} else if (enosys >= 8) {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
class SteamClientSetupFailure(val curlError: String?) {
|
||||
val download get() = curlError != null
|
||||
|
||||
companion object {
|
||||
const val MARKER = "== steam: the Steam client could not be set up"
|
||||
private const val STEP = "checking the Steam client"
|
||||
private const val X64_STEP = "checking the x86-64 Steam client"
|
||||
private val CURL_ERROR = Regex("""curl: \(\d+\).*""")
|
||||
|
||||
fun find(lines: Sequence<String>): SteamClientSetupFailure? {
|
||||
var curlError: String? = null
|
||||
var found: SteamClientSetupFailure? = null
|
||||
lines.forEach { line ->
|
||||
when {
|
||||
line.contains(STEP) || line.contains(X64_STEP) -> {
|
||||
curlError = null
|
||||
found = null
|
||||
}
|
||||
line.contains(MARKER) -> found = SteamClientSetupFailure(curlError)
|
||||
else -> CURL_ERROR.find(line)?.let { curlError = it.value.trim() }
|
||||
}
|
||||
}
|
||||
return found
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user