Skip to content
16 changes: 2 additions & 14 deletions Plain Craft Launcher 2/Modules/ModSecret.vb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Imports System.ComponentModel
Imports System.Management
Imports System.Net.Http
Imports System.Runtime.InteropServices
Imports System.Security
Imports System.Security.Cryptography
Imports PCL.Core.IO
Imports PCL.Core.UI
Expand Down Expand Up @@ -692,8 +693,6 @@ PCL-Community 及其成员与龙腾猫跃无从属关系,且均不会为您的
})

Public Function GetCurrentUpdateChannel() As UpdateChannel
If VersionBaseName.Contains("nightly") Then Return UpdateChannel.nightly
If VersionBaseName.Contains("beta") Then Return UpdateChannel.beta
Select Case CType(Setup.Get("SystemSystemUpdateBranch"), Integer)
Case 1
Return UpdateChannel.beta
Expand Down Expand Up @@ -733,17 +732,6 @@ PCL-Community 及其成员与龙腾猫跃无从属关系,且均不会为您的
End Function
Public Sub NoticeUserUpdate(Optional Silent As Boolean = False)
Dim channel = GetCurrentUpdateChannel()
If channel = UpdateChannel.nightly Then
If Not IsVerisonLatest() Then
Dim latest = RemoteServer.GetLatestVersion(channel, If(IsArm64System, UpdateArch.arm64, UpdateArch.x64))
If MyMsgBoxMarkdown($"启动器有新版本可用({VersionBaseName} -> {latest.VersionName})。由于你选择了 Nightly 更新通道,需要立即更新才能继续使用。{vbCrLf}{vbCrLf}{latest.Changelog}", "启动器更新", "更新", "或者更新", ForceWait:=True) = 1 Or 2 Then
UpdateStart(False)
End If
Else
If Not Silent Then Hint("启动器已是最新版 " + VersionBaseName + ",无须更新啦!", HintType.Finish)
End If
Return
End If

If Not IsVerisonLatest() Then
Dim latest As VersionDataModel = Nothing
Expand Down Expand Up @@ -787,7 +775,7 @@ PCL-Community 及其成员与龙腾猫跃无从属关系,且均不会为您的
Loaders.Add(New LoaderTask(Of Integer, Integer)("校验更新", Sub()
Dim curHash = GetFileSHA256(DlTargetPath)
If curHash <> version.SHA256 Then
Throw New Exception($"更新文件 SHA256 不正确,应该为 {version.SHA256},实际为 {curHash}")
Throw New SecurityException($"更新文件 SHA256 不正确,应该为 {version.SHA256},实际为 {curHash}")
End If
End Sub))
If Not Slient Then
Expand Down
8 changes: 4 additions & 4 deletions Plain Craft Launcher 2/Modules/Updates/UpdatesGitHubModel.vb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Public Class UpdatesGitHubModel

Public Function GetLatestVersion(channel As UpdateChannel, arch As UpdateArch) As VersionDataModel Implements IUpdateSource.GetLatestVersion
If channel <> UpdateChannel.nightly Then Throw New NotSupportedException("UpdatesGitHubModel only supports the Nightly channel.")
If _nightlyInfo Is Nothing AndAlso Not RefreshCache() Then Throw New Exception("Failed to get nightly update info.")
If _nightlyInfo Is Nothing AndAlso Not RefreshCache() Then Throw New InvalidOperationException("Failed to get nightly update info.")

Dim asset = GetAssetForArch(arch)

Expand All @@ -54,7 +54,7 @@ Public Class UpdatesGitHubModel

Public Function GetDownloadLoader(channel As UpdateChannel, arch As UpdateArch, output As String) As List(Of LoaderBase) Implements IUpdateSource.GetDownloadLoader
If channel <> UpdateChannel.nightly Then Throw New NotSupportedException("UpdatesGitHubModel only supports the Nightly channel.")
If _nightlyInfo Is Nothing AndAlso Not RefreshCache() Then Throw New Exception("Failed to get nightly update info for download.")
If _nightlyInfo Is Nothing AndAlso Not RefreshCache() Then Throw New InvalidOperationException("Failed to get nightly update info for download.")

Dim asset = GetAssetForArch(arch)
Dim downloadUrl = asset.download_url
Expand All @@ -69,7 +69,7 @@ Public Class UpdatesGitHubModel
Using fs As New IO.FileStream(tempPath, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
Using zip As New ZipArchive(fs)
Dim entry = zip.Entries.FirstOrDefault(Function(x) x.Name.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))
If entry Is Nothing Then Throw New Exception("在下载的更新包中找不到可执行文件。")
If entry Is Nothing Then Throw New InvalidOperationException("在下载的更新包中找不到可执行文件。")
entry.ExtractToFile(output, True)
End Using
End Using
Expand All @@ -80,7 +80,7 @@ Public Class UpdatesGitHubModel
Private Function GetAssetForArch(arch As UpdateArch) As NightlyAsset
Dim archName = If(arch = UpdateArch.arm64, "arm64", "x64")
Dim asset = _nightlyInfo.assets.FirstOrDefault(Function(a) a.arch.Equals(archName, StringComparison.OrdinalIgnoreCase))
If asset Is Nothing Then Throw New Exception($"Nightly build for architecture {archName} not found.")
If asset Is Nothing Then Throw New InvalidOperationException($"Nightly build for architecture {archName} not found.")
Return asset
End Function

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Class PageSetupSystem
ComboSystemUpdate.SelectedIndex = Setup.Get("SystemSystemUpdate")
Dim branch As Integer = Setup.Get("SystemSystemUpdateBranch")
ComboSystemUpdateBranch.SelectedIndex = branch
If branch = 1 OrElse branch = 2 OrElse VersionBaseName.Contains("nightly") Then
If branch = 1 OrElse branch = 2 Then
ComboSystemUpdateBranch.IsEnabled = False
Else
ComboSystemUpdateBranch.IsEnabled = True
Expand Down
Loading