LocalResourceLoaders.vb 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. Public Module LocalResourceLoaders
  2. '加载 Mod 列表
  3. Public LocalResourceLoader As New LoaderTask(Of String, List(Of LocalResourceFile))("LocalResourceLoader", AddressOf LocalResourceFileLoad)
  4. Private Sub LocalResourceFileLoad(Loader As LoaderTask(Of String, List(Of LocalResourceFile)))
  5. Try
  6. RunInUiWait(Sub() If FrmInstanceMod IsNot Nothing Then FrmInstanceMod.Load.ShowProgress = False)
  7. '等待 Mod 更新完成
  8. If PageInstanceMod.UpdatingInstanceModFolders.Contains(Loader.Input) Then
  9. Logger.Info($"等待 Mod 更新完成后才能继续加载 Mod 列表:{Loader.Input}")
  10. Try
  11. RunInUiWait(Sub() If FrmInstanceMod IsNot Nothing Then FrmInstanceMod.Load.Text = "正在更新 Mod")
  12. Do Until Not PageInstanceMod.UpdatingInstanceModFolders.Contains(Loader.Input)
  13. If Loader.IsCanceled Then Return
  14. Thread.Sleep(100)
  15. Loop
  16. Finally
  17. RunInUiWait(Sub() If FrmInstanceMod IsNot Nothing Then FrmInstanceMod.Load.Text = "正在加载 Mod 列表")
  18. End Try
  19. FrmInstanceMod.LoaderRun(LoaderFolderRunType.UpdateOnly)
  20. End If
  21. '获取 Mod 文件夹下的可用文件列表
  22. Dim ModFileList As New List(Of String)
  23. If DirectoryUtils.Exists(Loader.Input) Then
  24. Dim RawName As String = Loader.Input.Lower
  25. For Each File In DirectoryUtils.EnumerateFiles(Loader.Input, True)
  26. If File.BeforeLast("\").Lower & "\" <> RawName Then
  27. '仅当 Forge 1.13- 且文件夹名与版本号相同时,才加载该子文件夹下的 Mod
  28. If Not (PageInstanceLeft.Instance IsNot Nothing AndAlso PageInstanceLeft.Instance.Version.HasForge AndAlso
  29. PageInstanceLeft.Instance.Version.Vanilla.Major < 13 AndAlso
  30. PathUtils.GetLastPart(PathUtils.RemoveLastPart(File)) = $"1.{PageInstanceLeft.Instance.Version.Vanilla.Major}.{PageInstanceLeft.Instance.Version.Vanilla.Build}") Then
  31. Continue For
  32. End If
  33. End If
  34. Static IsModFile As Func(Of String, Boolean) =
  35. Function(FullName As String)
  36. If FullName Is Nothing OrElse Not FullName.Contains(".") Then Return False
  37. FullName = FullName.Lower
  38. If FullName.EndsWithF(".jar", True) OrElse FullName.EndsWithF(".zip", True) OrElse FullName.EndsWithF(".litemod", True) OrElse
  39. FullName.EndsWithF(".jar.disabled", True) OrElse FullName.EndsWithF(".zip.disabled", True) OrElse FullName.EndsWithF(".litemod.disabled", True) OrElse
  40. FullName.EndsWithF(".jar.old", True) OrElse FullName.EndsWithF(".zip.old", True) OrElse FullName.EndsWithF(".litemod.old", True) Then Return True
  41. Return False
  42. End Function
  43. If IsModFile(File) Then ModFileList.Add(File)
  44. Next
  45. End If
  46. '获取本地文件缓存
  47. Dim CachePath As String = PathTemp & "Cache\LocalMod.json"
  48. Dim Cache As New JObject
  49. Try
  50. Dim CacheContent As String = FileUtils.TryReadAsString(CachePath)
  51. If Not String.IsNullOrWhiteSpace(CacheContent) Then
  52. Cache = CacheContent.DeserializeJson()
  53. If Not Cache.ContainsKey("version") OrElse Cache("version").ToObject(Of Integer) <> Versions.LocalModCacheVersion Then
  54. Logger.Warn($"本地 Mod 信息缓存版本已过期,将弃用这些缓存信息")
  55. Cache = New JObject
  56. End If
  57. End If
  58. Catch ex As Exception
  59. Logger.Warn(ex, "读取本地 Mod 信息缓存失败,已重置")
  60. Cache = New JObject
  61. End Try
  62. Cache("version") = Versions.LocalModCacheVersion
  63. '加载 Mod 列表
  64. Dim ModList As New List(Of LocalResourceFile)
  65. For Each ModFile In ModFileList
  66. If Loader.IsCanceled Then Return
  67. Dim ModEntry As New LocalResourceFile(ModFile)
  68. Dim DumpMod As LocalResourceFile = ModList.FirstOrDefault(Function(m) m.EnabledName = ModEntry.EnabledName) '存在两个文件,名称相同,但一个启用一个禁用
  69. If DumpMod IsNot Nothing Then
  70. Dim DisabledMod As LocalResourceFile = If(DumpMod.IsEnabled, ModEntry, DumpMod)
  71. Logger.Warn($"重复的 Mod 文件:{DumpMod.File.Name} 与 {ModEntry.File.Name},已忽略 {DisabledMod.File.Name}")
  72. If DisabledMod Is ModEntry Then
  73. Continue For
  74. Else
  75. ModList.Remove(DisabledMod)
  76. End If
  77. End If
  78. ModList.Add(ModEntry)
  79. Next
  80. Logger.Info($"共发现 {ModList.Count} 个 Mod")
  81. '排序
  82. ModList = ModList.OrderBy(Function(m) m.File.Name).ToList
  83. '回设
  84. If Loader.IsCanceled Then Return
  85. Loader.Output = ModList
  86. '开始联网加载
  87. 'TODO: 添加信息获取中提示
  88. LocalResourceOnlineLoader.Start((ModList, Cache, PageInstanceLeft.Instance.Version), IsForceRestart:=True)
  89. Catch ex As Exception
  90. Logger.Warn(ex, "Mod 列表加载失败")
  91. Throw
  92. End Try
  93. End Sub
  94. '联网加载 Mod 详情
  95. Public LocalResourceOnlineLoader As New LoaderTask(Of (ModList As List(Of LocalResourceFile), Cache As JObject, Target As McVersion), Integer)("LocalResourceOnlineLoader", AddressOf LocalResourceOnlineLoad)
  96. Private Sub LocalResourceOnlineLoad(Loader As LoaderTask(Of (ModList As List(Of LocalResourceFile), Cache As JObject, Target As McVersion), Integer))
  97. Dim Mods As New List(Of LocalResourceFile)
  98. Dim Cache As JObject = Loader.Input.Cache
  99. Dim ModLoaders = Loader.Input.Target.ModLoaders
  100. '读取缓存,获取需要更新的 Mod 列表
  101. For Each ModEntry As LocalResourceFile In Loader.Input.ModList
  102. If Loader.IsCanceled Then Return
  103. Dim CacheKey = ModEntry.ModrinthHash & Loader.Input.Target.VanillaName & ModLoaders
  104. If Cache.ContainsKey(CacheKey) Then
  105. ModEntry.FromJson(Cache(CacheKey))
  106. '如果缓存中的信息在 6 小时以内更新过,则无需重新获取
  107. If ModEntry.OnlineDataLoaded AndAlso Date.Now - Cache(CacheKey)("Project")("CacheTime").ToObject(Of Date) < New TimeSpan(6, 0, 0) Then Continue For
  108. End If
  109. Mods.Add(ModEntry)
  110. Next
  111. Logger.Info($"有 {Mods.Where(Function(m) m.Project Is Nothing).Count} 个 Mod 需要联网获取信息,{Mods.Where(Function(m) m.Project IsNot Nothing).Count} 个 Mod 需要更新信息")
  112. If Not Mods.Any Then Return
  113. '获取作为检查目标的版本
  114. '此处不应向下扩展检查的 MC 小版本,例如 Mod 在更新 1.16.5 后,对早期的 1.16.2 版本发布了修补补丁,这会导致 PCL 将 1.16.5 版本的 Mod 降级到 1.16.2
  115. Dim TargetMcVersion As McVersion = Loader.Input.Target
  116. Dim VanillaVersion = TargetMcVersion.VanillaName
  117. '开始网络获取
  118. Logger.Info($"正在检查 Mod 信息的版本:{VanillaVersion},加载器 {ModLoaders}")
  119. Dim EndedThreadCount As Integer = 0, IsFailed As Boolean = False
  120. Dim CurrentTaskThread As Thread = Thread.CurrentThread
  121. '从 Modrinth 获取信息
  122. RunInNewThread(
  123. Sub()
  124. Try
  125. '步骤 1:获取 Hash 与对应的工程 ID
  126. Dim ModrinthHashes = Mods.Select(Function(m) m.ModrinthHash).ToList()
  127. Dim ModrinthVersion As JObject = DlModRequest("https://api.modrinth.com/v2/version_files", HttpMethod.Post,
  128. $"{{""hashes"": [""{ModrinthHashes.Join(""",""")}""], ""algorithm"": ""sha1""}}", "application/json")
  129. Logger.Info($"从 Modrinth 获取到 {ModrinthVersion.Count} 个本地 Mod 的对应信息")
  130. '步骤 2:尝试读取工程信息缓存,构建其他 Mod 的对应关系
  131. If ModrinthVersion.Count = 0 Then Return
  132. Dim ModrinthMapping As New Dictionary(Of String, List(Of LocalResourceFile))
  133. Dim ModrinthLoaders As New Dictionary(Of LocalResourceFile, List(Of String))
  134. For Each Entry In Mods
  135. If Not ModrinthVersion.ContainsKey(Entry.ModrinthHash) Then Continue For
  136. If ModrinthVersion(Entry.ModrinthHash)("files")(0)("hashes")("sha1") <> Entry.ModrinthHash Then Continue For
  137. Dim ProjectId = ModrinthVersion(Entry.ModrinthHash)("project_id").ToString
  138. If ResourceProject.Cache.ContainsKey(ProjectId) AndAlso Entry.Project Is Nothing Then Entry.Project = ResourceProject.Cache(ProjectId) '读取已加载的缓存,加快结果出现速度
  139. If Not ModrinthMapping.ContainsKey(ProjectId) Then ModrinthMapping(ProjectId) = New List(Of LocalResourceFile)
  140. ModrinthMapping(ProjectId).Add(Entry)
  141. '记录对应的 ProjectVersion
  142. Dim File = ResourceVersion.FromPlatformJson(ModrinthVersion(Entry.ModrinthHash), ResourceTypes.Mod)
  143. ModrinthLoaders(Entry) = ModrinthVersion(Entry.ModrinthHash)("loaders").
  144. Select(Function(l) l.ToString.Lower).Distinct.OrderBy(Function(l) l).ToList
  145. If Entry.ProjectVersion Is Nothing OrElse Entry.ProjectVersion.ReleaseDate < File.ReleaseDate Then
  146. Entry.ProjectVersion = File
  147. Else
  148. Entry.ProjectVersion.Version = File.Version '使用来自 Modrinth 的版本号
  149. End If
  150. Next
  151. If Loader.IsCanceledWithThread(CurrentTaskThread) Then Return
  152. Logger.Info($"需要从 Modrinth 获取 {ModrinthMapping.Count} 个本地 Mod 的工程信息")
  153. '步骤 3:获取工程信息
  154. If Not ModrinthMapping.Any() Then Return
  155. Dim ModrinthProject As JArray = DlModRequest(
  156. $"https://api.modrinth.com/v2/projects?ids=[""{ModrinthMapping.Keys.Join(""",""")}""]")
  157. For Each ProjectJson In ModrinthProject
  158. Dim Project As New ResourceProject(ProjectJson)
  159. For Each Entry In ModrinthMapping(Project.Id)
  160. Entry.Project = Project
  161. Next
  162. Next
  163. Logger.Info($"已从 Modrinth 获取本地 Mod 信息,继续获取更新信息")
  164. '步骤 4:获取更新信息
  165. Dim ModsToUpdate = ModrinthMapping.SelectMany(Function(l) l.Value).ToList
  166. If Not ModsToUpdate.Any Then Return
  167. Dim UpdateData As String = ModsToUpdate.
  168. Select(Function(m) $"{{""hash"": ""{m.ModrinthHash}"", ""loaders"": [""{ModrinthLoaders(m).Join(""",""")}""], ""game_versions"": [""{VanillaVersion}""]}}").
  169. Join(",")
  170. Dim ModrinthUpdate As JObject = DlModRequest("https://api.modrinth.com/v2/version_files/update_individual", HttpMethod.Post,
  171. $"{{""algorithm"": ""sha1"", ""hashes"": [{UpdateData}]}}", "application/json")
  172. For Each Entry In Mods
  173. If Not ModrinthUpdate.ContainsKey(Entry.ModrinthHash) OrElse Entry.ProjectVersion Is Nothing Then Continue For
  174. Dim UpdateFile = ResourceVersion.FromPlatformJson(ModrinthUpdate(Entry.ModrinthHash), ResourceTypes.Mod)
  175. If Not UpdateFile.DownloadAvailable Then Continue For
  176. Dim UpdateLoaders = ModrinthUpdate(Entry.ModrinthHash)("loaders").
  177. Select(Function(l) l.ToString.Lower).Distinct.OrderBy(Function(l) l).ToList
  178. If Not UpdateLoaders.SequenceEqual(ModrinthLoaders(Entry)) Then Continue For
  179. Logger.Trace(Function() $"本地文件 {Entry.ProjectVersion.FileName} 在 Modrinth 上的最新版为 {UpdateFile.FileName}")
  180. If Entry.ProjectVersion.ReleaseDate >= UpdateFile.ReleaseDate OrElse Entry.ProjectVersion.Hash = UpdateFile.Hash Then Continue For
  181. '设置更新日志与更新文件
  182. If Entry.UpdateFile IsNot Nothing AndAlso UpdateFile.Hash = Entry.UpdateFile.Hash Then '合并
  183. Entry.ChangelogUrls.Add($"https://modrinth.com/mod/{ModrinthUpdate(Entry.ModrinthHash)("project_id")}/changelog?g={VanillaVersion}")
  184. UpdateFile.DownloadUrls.AddRange(Entry.UpdateFile.DownloadUrls) '合并下载源
  185. Entry.UpdateFile = UpdateFile '优先使用 Modrinth 的文件
  186. ElseIf Entry.UpdateFile Is Nothing OrElse UpdateFile.ReleaseDate >= Entry.UpdateFile.ReleaseDate Then '替换
  187. Entry.ChangelogUrls = New List(Of String) From {$"https://modrinth.com/mod/{ModrinthUpdate(Entry.ModrinthHash)("project_id")}/changelog?g={VanillaVersion}"}
  188. Entry.UpdateFile = UpdateFile
  189. End If
  190. Next
  191. Logger.Info($"从 Modrinth 获取本地 Mod 信息结束")
  192. Catch ex As Exception
  193. Logger.Warn(ex, "从 Modrinth 获取本地 Mod 信息失败")
  194. IsFailed = True
  195. Finally
  196. EndedThreadCount += 1
  197. End Try
  198. End Sub, "Mod List Detail Loader Modrinth")
  199. '从 CurseForge 获取信息
  200. RunInNewThread(
  201. Sub()
  202. Try
  203. '步骤 1:获取 Hash 与对应的工程 ID
  204. Dim Hashes As New List(Of UInteger)
  205. For Each Entry In Mods
  206. Hashes.Add(Entry.CurseForgeHash)
  207. If Loader.IsCanceledWithThread(CurrentTaskThread) Then Return
  208. Next
  209. Dim CurseForgeRaw As JContainer = DlModRequest("https://api.curseforge.com/v1/fingerprints/432", HttpMethod.Post,
  210. $"{{""fingerprints"": [{Hashes.Join(",")}]}}", "application/json")("data")("exactMatches")
  211. Logger.Info($"从 CurseForge 获取到 {CurseForgeRaw.Count} 个本地 Mod 的对应信息")
  212. If Not CurseForgeRaw.Any() Then Return
  213. '步骤 2:尝试读取工程信息缓存,构建其他 Mod 的对应关系
  214. Dim ProjectIdToLocalFiles As New Dictionary(Of Integer, List(Of LocalResourceFile))
  215. Dim CurseForgeLoaders As New Dictionary(Of LocalResourceFile, ModLoaders)
  216. For Each Project In CurseForgeRaw
  217. Dim ProjectId = Project("id").ToString
  218. Dim Hash As UInteger = Project("file")("fileFingerprint")
  219. For Each Entry In Mods
  220. If Entry.CurseForgeHash <> Hash Then Continue For
  221. If ResourceProject.Cache.ContainsKey(ProjectId) AndAlso Entry.Project Is Nothing Then Entry.Project = ResourceProject.Cache(ProjectId) '读取已加载的缓存,加快结果出现速度
  222. ProjectIdToLocalFiles.AddIntoValueCollection(ProjectId, Entry)
  223. '记录对应的 ProjectVersion
  224. Dim File = ResourceVersion.FromPlatformJson(Project("file"), ResourceTypes.Mod)
  225. CurseForgeLoaders(Entry) = File.ModLoaders
  226. If Entry.ProjectVersion Is Nothing OrElse Entry.ProjectVersion.ReleaseDate < File.ReleaseDate Then Entry.ProjectVersion = File
  227. Next
  228. Next
  229. If Loader.IsCanceledWithThread(CurrentTaskThread) Then Return
  230. Logger.Info($"需要从 CurseForge 获取 {ProjectIdToLocalFiles.Count} 个本地 Mod 的工程信息")
  231. If Not ProjectIdToLocalFiles.Any() Then Return
  232. '步骤 3:获取工程信息
  233. Dim CurseForgeProject = DlModRequest("https://api.curseforge.com/v1/mods", HttpMethod.Post,
  234. $"{{""modIds"": [{ProjectIdToLocalFiles.Keys.Join(",")}]}}", "application/json")("data")
  235. Dim UpdateFileIds As New Dictionary(Of Integer, List(Of LocalResourceFile)) 'FileId -> 本地 Mod 文件列表
  236. Dim FileIdToProjectSlug As New Dictionary(Of Integer, String)
  237. For Each ProjectJson In CurseForgeProject
  238. If ProjectJson("isAvailable") IsNot Nothing AndAlso Not ProjectJson("isAvailable").ToObject(Of Boolean) Then Continue For
  239. '设置 Entry 中的工程信息
  240. Dim Project As New ResourceProject(ProjectJson)
  241. For Each LocalFile In ProjectIdToLocalFiles(Project.Id) '倒查防止 CurseForge 返回的内容有漏
  242. If LocalFile.Project?.Platform = ResourcePlatforms.Modrinth Then
  243. LocalFile.Project = LocalFile.Project '再次触发修改事件
  244. Else
  245. LocalFile.Project = Project
  246. End If
  247. '查找可能有版本更新的文件列表
  248. Dim LatestFiles = ProjectJson("latestFilesIndexes").Where(
  249. Function(Entry)
  250. 'Mod Loader 匹配
  251. Dim EntryLoader As ModLoaders = If(Entry("modLoader") Is Nothing, ModLoaders.None,
  252. Resource.FromCurseForgeModLoaderType(Entry("modLoader").ToObject(Of Integer)))
  253. If CurseForgeLoaders(LocalFile) = ModLoaders.None Then
  254. If EntryLoader <> ModLoaders.None Then Return False
  255. ElseIf Not CurseForgeLoaders(LocalFile).HasFlagF(EntryLoader) Then
  256. Return False
  257. End If
  258. 'MC 版本匹配
  259. Dim EntryVersion As String = Entry("gameVersion")
  260. Return EntryVersion IsNot Nothing AndAlso EntryVersion = VanillaVersion
  261. End Function).
  262. MaxByAll(Function(Entry) Entry("gameVersion").ToString, New VersionComparer) '只保留最新的 MC 版本
  263. For Each Entry In LatestFiles
  264. Dim FileId = Entry("fileId").ToObject(Of Integer)
  265. If Not UpdateFileIds.ContainsKey(FileId) Then UpdateFileIds(FileId) = New List(Of LocalResourceFile)
  266. UpdateFileIds(FileId).Add(LocalFile)
  267. FileIdToProjectSlug(FileId) = Project.Slug
  268. Next
  269. Next
  270. Next
  271. Logger.Info($"已从 CurseForge 获取本地 Mod 信息,需要获取 {UpdateFileIds.Count} 个用于检查更新的文件信息")
  272. If Not UpdateFileIds.Any() Then Return
  273. '步骤 4:获取更新文件信息
  274. Dim CurseForgeFiles = DlModRequest("https://api.curseforge.com/v1/mods/files", HttpMethod.Post,
  275. $"{{""fileIds"": [{UpdateFileIds.Keys.Join(",")}]}}", "application/json")("data")
  276. Dim UpdateFiles As New Dictionary(Of LocalResourceFile, ResourceVersion)
  277. For Each FileJson In CurseForgeFiles
  278. Dim File = ResourceVersion.FromPlatformJson(FileJson, ResourceTypes.Mod)
  279. If Not File.DownloadAvailable Then Continue For
  280. For Each Entry As LocalResourceFile In UpdateFileIds(File.Id)
  281. If File.ModLoaders <> CurseForgeLoaders(Entry) Then
  282. Logger.Warn($"从 CurseForge 获取到的更新文件 {File.FileName} 加载器为 {File.ModLoaders},与本地文件 {Entry.File.Name} 的加载器 {CurseForgeLoaders(Entry)} 不一致,已忽略", LogBehavior.None)
  283. Continue For
  284. End If
  285. If UpdateFiles.ContainsKey(Entry) AndAlso UpdateFiles(Entry).ReleaseDate >= File.ReleaseDate Then Continue For
  286. UpdateFiles(Entry) = File
  287. Next
  288. Next
  289. For Each Pair In UpdateFiles
  290. Dim Entry As LocalResourceFile = Pair.Key
  291. Dim UpdateFile As ResourceVersion = Pair.Value
  292. Logger.Trace(Function() $"本地文件 {Entry.ProjectVersion.FileName} 在 CurseForge 上的最新版为 {UpdateFile.FileName}")
  293. If Entry.ProjectVersion.ReleaseDate >= UpdateFile.ReleaseDate OrElse Entry.ProjectVersion.Hash = UpdateFile.Hash Then Continue For
  294. '设置更新日志与更新文件
  295. If Entry.UpdateFile IsNot Nothing AndAlso UpdateFile.Hash = Entry.UpdateFile.Hash Then '合并
  296. Entry.ChangelogUrls.Add($"https://www.curseforge.com/minecraft/mc-mods/{FileIdToProjectSlug(UpdateFile.Id)}/files/{UpdateFile.Id}")
  297. Entry.UpdateFile.DownloadUrls.AddRange(UpdateFile.DownloadUrls) '合并下载源
  298. ElseIf Entry.UpdateFile Is Nothing OrElse UpdateFile.ReleaseDate > Entry.UpdateFile.ReleaseDate Then '替换
  299. Entry.ChangelogUrls = New List(Of String) From {$"https://www.curseforge.com/minecraft/mc-mods/{FileIdToProjectSlug(UpdateFile.Id)}/files/{UpdateFile.Id}"}
  300. Entry.UpdateFile = UpdateFile
  301. End If
  302. Next
  303. Logger.Info($"从 CurseForge 获取 Mod 更新信息结束")
  304. Catch ex As Exception
  305. Logger.Warn(ex, "从 CurseForge 获取本地 Mod 信息失败")
  306. IsFailed = True
  307. Finally
  308. EndedThreadCount += 1
  309. End Try
  310. End Sub, "Mod List Detail Loader CurseForge")
  311. '等待线程结束
  312. Do Until EndedThreadCount = 2
  313. Thread.Sleep(10)
  314. If Loader.IsCanceled Then Return
  315. Loop
  316. '保存缓存
  317. Mods = Mods.Where(Function(m) m.Project IsNot Nothing).ToList()
  318. Logger.Info($"联网获取本地 Mod 信息完成,为 {Mods.Count} 个 Mod 更新缓存")
  319. If Not Mods.Any() Then Return
  320. If Loader.IsCanceled Then Return
  321. For Each Entry In Mods
  322. Entry.OnlineDataLoaded = Not IsFailed
  323. Cache(Entry.ModrinthHash & VanillaVersion & ModLoaders) = Entry.ToJson()
  324. Next
  325. FileUtils.Write(PathTemp & "Cache\LocalMod.json", Cache.ToString(If(ModeDebug, Newtonsoft.Json.Formatting.Indented, Newtonsoft.Json.Formatting.None)))
  326. '刷新边栏
  327. If Loader.IsCanceled Then Return
  328. If FrmInstanceMod?.Filter = PageInstanceMod.FilterType.CanUpdate Then
  329. RunInUi(Sub() FrmInstanceMod?.RefreshUI()) '同步 “可更新” 列表 (#4677)
  330. Else
  331. RunInUi(Sub() FrmInstanceMod?.RefreshBars())
  332. End If
  333. End Sub
  334. End Module