refactor: leverage new dependency features from recent updates (#5057)

This commit is contained in:
James Rich 2026-04-10 17:51:08 -05:00 committed by GitHub
parent 929e273978
commit 9c8532f80d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 47 additions and 57 deletions

View file

@ -17,7 +17,9 @@
package org.meshtastic.feature.firmware.ota.dfu
import co.touchlab.kermit.Logger
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonDecodingException
private val json = Json { ignoreUnknownKeys = true }
@ -36,7 +38,11 @@ internal fun parseDfuZipEntries(entries: Map<String, ByteArray>): DfuZipPackage
val manifest =
runCatching { json.decodeFromString<DfuManifest>(manifestBytes.decodeToString()) }
.getOrElse { e -> throw DfuException.InvalidPackage("Failed to parse manifest.json: ${e.message}") }
.getOrElse { e ->
@OptIn(ExperimentalSerializationApi::class)
val detail = (e as? JsonDecodingException)?.shortMessage ?: e.message
throw DfuException.InvalidPackage("Failed to parse manifest.json: $detail")
}
val entry =
manifest.manifest.primaryEntry ?: throw DfuException.InvalidPackage("No firmware entry found in manifest.json")