mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
fix: the Steam download monitor no longer stalls the main thread on a long content log
The content log was read with RandomAccessFile.readLine, one byte per read, on the main thread. A 4 MB log took about 2 s on the first poll, enough for an ANR on slower devices while a download runs. It is now read through a buffered reader with the same Latin-1 lines and offset, and the per-line regexes only run on lines that can match.
This commit is contained in:
1 parent
b0e405ebf3
commit
dd79f44b3a
2 files changed
+31
-7
No files matched your search
@@ -101,6 +101,28 @@ class SteamDownloadMonitorTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun aLongLogIsFollowedFromWhereTheLastPollStopped() {
|
||||
val root = Files.createTempDirectory("droiddeck-steam-download-").toFile()
|
||||
try {
|
||||
val contentLog = File(root, "root/.local/share/Steam/logs/content_log.txt").apply {
|
||||
check(parentFile?.mkdirs() != false)
|
||||
writeText(buildString {
|
||||
repeat(5_000) { append("[2026-10-06 14:40:00] Detected write gap 64 MB in file \"data_$it.dat\"\r\n") }
|
||||
append("[2026-10-06 14:44:17] AppID 44 App update changed : Running Update,Downloading,\r\n")
|
||||
})
|
||||
}
|
||||
val monitor = SteamDownloadMonitor()
|
||||
|
||||
assertTrue(monitor.poll(root, now = 1_000L))
|
||||
contentLog.appendText("[2026-10-06 14:45:03] AppID 44 App update changed : None\r\n")
|
||||
assertFalse(monitor.poll(root, now = 2_000L))
|
||||
contentLog.appendText("[2026-10-06 14:46:00] AppID 45 App update changed : Running Update,Downloading,\r\n")
|
||||
assertTrue(monitor.poll(root, now = 3_000L))
|
||||
} finally {
|
||||
root.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun theOtherClientsLogIsReadFromItsStart() {
|
||||
val root = Files.createTempDirectory("droiddeck-steam-download-").toFile()
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user