fix(diagnostics): stabilize pending crash ordering

This commit is contained in:
2026-07-21 18:23:50 +02:00
parent a8a873c83d
commit 873ec6fd94
2 changed files with 11 additions and 2 deletions

View File

@@ -31,10 +31,13 @@ private class JvmPendingCrashStore(
return directory
.listFiles { file -> file.isFile && file.name.endsWith(".crash") }
.orEmpty()
.sortedByDescending { it.lastModified() }
.mapNotNull { file ->
runCatching { CrashReportCodec.decode(file.readText(StandardCharsets.UTF_8)) }.getOrNull()
}
.sortedWith(
compareByDescending<CrashReport> { it.timestampMillis }
.thenBy { it.id },
)
}
@Synchronized
@@ -64,7 +67,10 @@ private class JvmPendingCrashStore(
file to report
}
}
.sortedByDescending { (_, report) -> report.timestampMillis }
.sortedWith(
compareByDescending<Pair<File, CrashReport>> { (_, report) -> report.timestampMillis }
.thenBy { (_, report) -> report.id },
)
reports.forEachIndexed { index, (file, report) ->
if (index >= maxCount || report.timestampMillis < olderThanTimestampMillis) file.delete()
}