fix(spoof): propagate read errors out of mergedContents

A read failure (partial-write race during user edit, SELinux
denial, or any other IOException) used to fall through the
runCatching and rewrite the file with only the global block,
silently destroying every existing [pkg] override. Drop the
runCatching so the failure bubbles to atomicWrite, where the M3
guard in updateTo logs and returns without applyToProps, leaving
both file and props untouched.
This commit is contained in:
Enginex0
2026-05-19 05:35:13 +01:00
parent d146ad8234
commit ad1a9b8c32
@@ -146,9 +146,7 @@ object PatchLevelManager {
private fun mergedContents(target: File, date: String): String { private fun mergedContents(target: File, date: String): String {
val globalBlock = "system=$date\nboot=$date\nvendor=$date\n" val globalBlock = "system=$date\nboot=$date\nvendor=$date\n"
if (!target.exists()) return globalBlock if (!target.exists()) return globalBlock
val tail = val tail = stripGlobalAssignments(target.readLines())
runCatching { stripGlobalAssignments(target.readLines()) }.getOrNull()
?: return globalBlock
if (tail.isEmpty()) return globalBlock if (tail.isEmpty()) return globalBlock
return globalBlock + tail.joinToString("\n", prefix = "\n", postfix = "\n") return globalBlock + tail.joinToString("\n", prefix = "\n", postfix = "\n")
} }