mirror of
https://github.com/jie65535/mirai-console-jcf-plugin.git
synced 2025-06-02 17:39:15 +08:00
调整 检查mod更新处改用批量搜索
This commit is contained in:
parent
09974aad9e
commit
21bcedcb17
@ -123,14 +123,22 @@ class SubscribeHandler(
|
|||||||
private suspend fun checkUpdate(init: Boolean = false) = flow {
|
private suspend fun checkUpdate(init: Boolean = false) = flow {
|
||||||
val oldSet = PluginData.modsLastFile
|
val oldSet = PluginData.modsLastFile
|
||||||
if (oldSet.isNotEmpty()) {
|
if (oldSet.isNotEmpty()) {
|
||||||
|
val fetchMods = service.getMods(oldSet.keys.toIntArray())
|
||||||
|
.asSequence()
|
||||||
|
.map { it.id to it }
|
||||||
|
.toMap()
|
||||||
for ((mod, old) in oldSet) {
|
for ((mod, old) in oldSet) {
|
||||||
try {
|
try {
|
||||||
val info = service.getMod(mod)
|
val new = fetchMods[mod]
|
||||||
logger.info("模组更新【${info.name}】")
|
if (new == null) {
|
||||||
MOD_INFO_CACHE[mod] = info
|
emit(mod to -1)
|
||||||
val last = info.latestFilesIndexes[0].fileId
|
continue
|
||||||
|
}
|
||||||
|
MOD_INFO_CACHE[mod] = new
|
||||||
|
val last = new.latestFilesIndexes[0].fileId
|
||||||
if (old != last || init) {
|
if (old != last || init) {
|
||||||
emit(mod to last)
|
emit(mod to last)
|
||||||
|
logger.info("模组更新【${new.name}】")
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.warning("err msg: ${e.message}")
|
logger.warning("err msg: ${e.message}")
|
||||||
|
Loading…
Reference in New Issue
Block a user