mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 13:07:39 +00:00
Fix network
This commit is contained in:
parent
fa2dbe981e
commit
da93bbc1fe
@ -20,7 +20,7 @@ class RepoUpdater(
|
|||||||
val cachedMap = HashMap<String, Date>().also { map ->
|
val cachedMap = HashMap<String, Date>().also { map ->
|
||||||
repoDB.getModuleStubs().forEach { map[it.id] = Date(it.last_update) }
|
repoDB.getModuleStubs().forEach { map[it.id] = Date(it.last_update) }
|
||||||
}.synchronized()
|
}.synchronized()
|
||||||
svc.fetchRepoInfo()?.also { info ->
|
svc.fetchRepoInfo()?.let { info ->
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
info.modules.forEach {
|
info.modules.forEach {
|
||||||
launch {
|
launch {
|
||||||
@ -36,7 +36,7 @@ class RepoUpdater(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
repoDB.removeModules(cachedMap.keys)
|
||||||
}
|
}
|
||||||
repoDB.removeModules(cachedMap.keys)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class NetworkService(
|
|||||||
private val jsd: JSDelivrServices,
|
private val jsd: JSDelivrServices,
|
||||||
private val api: GithubApiServices
|
private val api: GithubApiServices
|
||||||
) {
|
) {
|
||||||
suspend fun fetchUpdate() = try {
|
suspend fun fetchUpdate() = safe {
|
||||||
var info = when (Config.updateChannel) {
|
var info = when (Config.updateChannel) {
|
||||||
DEFAULT_CHANNEL, STABLE_CHANNEL -> fetchStableUpdate()
|
DEFAULT_CHANNEL, STABLE_CHANNEL -> fetchStableUpdate()
|
||||||
BETA_CHANNEL -> fetchBetaUpdate()
|
BETA_CHANNEL -> fetchBetaUpdate()
|
||||||
@ -36,12 +36,6 @@ class NetworkService(
|
|||||||
}
|
}
|
||||||
Info.remote = info
|
Info.remote = info
|
||||||
info
|
info
|
||||||
} catch (e: IOException) {
|
|
||||||
Timber.e(e)
|
|
||||||
null
|
|
||||||
} catch (e: HttpException) {
|
|
||||||
Timber.e(e)
|
|
||||||
null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateInfo
|
// UpdateInfo
|
||||||
@ -69,7 +63,7 @@ class NetworkService(
|
|||||||
private inline fun <T> safe(factory: () -> T): T? {
|
private inline fun <T> safe(factory: () -> T): T? {
|
||||||
return try {
|
return try {
|
||||||
factory()
|
factory()
|
||||||
} catch (e: HttpException) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e)
|
Timber.e(e)
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ import com.topjohnwu.magisk.utils.set
|
|||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.koin.core.get
|
import org.koin.core.get
|
||||||
|
import timber.log.Timber
|
||||||
|
import java.io.IOException
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
class InstallViewModel(
|
class InstallViewModel(
|
||||||
@ -64,7 +66,11 @@ class InstallViewModel(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
notes = svc.fetchString(Info.remote.magisk.note)
|
try {
|
||||||
|
notes = svc.fetchString(Info.remote.magisk.note)
|
||||||
|
} catch (e: IOException) {
|
||||||
|
Timber.e(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user