mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-10-27 14:31:30 +00:00
Make fetchUpdate safe
This commit is contained in:
@@ -73,7 +73,8 @@ class InstallViewModel(svc: NetworkService, markwon: Markwon) : BaseViewModel()
|
|||||||
val noteText = when {
|
val noteText = when {
|
||||||
noteFile.exists() -> noteFile.readText()
|
noteFile.exists() -> noteFile.readText()
|
||||||
else -> {
|
else -> {
|
||||||
val note = svc.fetchUpdate(APP_VERSION_CODE).note
|
val note = svc.fetchUpdate(APP_VERSION_CODE)?.note.orEmpty()
|
||||||
|
if (note.isEmpty()) return@launch
|
||||||
noteFile.writeText(note)
|
noteFile.writeText(note)
|
||||||
note
|
note
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ class NetworkService(
|
|||||||
info
|
info
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun fetchUpdate(version: Int) = findRelease { it.versionCode == version }.asInfo()
|
suspend fun fetchUpdate(version: Int) = safe {
|
||||||
|
findRelease { it.versionCode == version }.asInfo()
|
||||||
|
}
|
||||||
|
|
||||||
// Keep going through all release pages until we find a match
|
// Keep going through all release pages until we find a match
|
||||||
private suspend inline fun findRelease(predicate: (Release) -> Boolean): Release? {
|
private suspend inline fun findRelease(predicate: (Release) -> Boolean): Release? {
|
||||||
|
|||||||
Reference in New Issue
Block a user