diff --git a/v2rayN/ServiceLib/Handler/TaskHandler.cs b/v2rayN/ServiceLib/Handler/TaskHandler.cs index e7b9ad932d..0add446a87 100644 --- a/v2rayN/ServiceLib/Handler/TaskHandler.cs +++ b/v2rayN/ServiceLib/Handler/TaskHandler.cs @@ -61,7 +61,7 @@ private async Task UpdateTaskRunGeo(Config config, Action update) { if ((dtNow - autoUpdateGeoTime).Hours % config.guiItem.autoUpdateInterval == 0) { - updateHandle.UpdateGeoFileAll(config, (bool success, string msg) => + await updateHandle.UpdateGeoFileAll(config, (bool success, string msg) => { update(false, msg); }); diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 43734d2e97..f5a110ad03 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -71,13 +71,6 @@ public class MainWindowViewModel : MyReactiveObject public ReactiveCommand ClearServerStatisticsCmd { get; } public ReactiveCommand OpenTheFileLocationCmd { get; } - //CheckUpdate - public ReactiveCommand CheckUpdateNCmd { get; } - - public ReactiveCommand CheckUpdateXrayCoreCmd { get; } - public ReactiveCommand CheckUpdateClashMetaCoreCmd { get; } - public ReactiveCommand CheckUpdateSingBoxCoreCmd { get; } - public ReactiveCommand CheckUpdateGeoCmd { get; } public ReactiveCommand ReloadCmd { get; } [Reactive] @@ -295,28 +288,6 @@ public MainWindowViewModel(Func>? updateView) Utils.ProcessStart("Explorer", $"/select,{Utils.GetConfigPath()}"); }); - //CheckUpdate - CheckUpdateNCmd = ReactiveCommand.Create(() => - { - CheckUpdateN(); - }); - CheckUpdateXrayCoreCmd = ReactiveCommand.Create(() => - { - CheckUpdateCore(ECoreType.Xray, null); - }); - CheckUpdateClashMetaCoreCmd = ReactiveCommand.Create(() => - { - CheckUpdateCore(ECoreType.mihomo, false); - }); - CheckUpdateSingBoxCoreCmd = ReactiveCommand.Create(() => - { - CheckUpdateCore(ECoreType.sing_box, null); - }); - CheckUpdateGeoCmd = ReactiveCommand.Create(() => - { - CheckUpdateGeo(); - }); - ReloadCmd = ReactiveCommand.Create(() => { Reload(); @@ -718,99 +689,6 @@ private void RebootAsAdmin() #endregion Setting - #region CheckUpdate - - private void CheckUpdateN() - { - //Check for standalone windows .Net version - if (Utils.IsWindows() - && File.Exists(Path.Combine(Utils.StartupPath(), "wpfgfx_cor3.dll")) - && File.Exists(Path.Combine(Utils.StartupPath(), "D3DCompiler_47_cor3.dll")) - ) - { - _noticeHandler?.SendMessageAndEnqueue(ResUI.UpdateStandalonePackageTip); - return; - } - - void _updateUI(bool success, string msg) - { - _noticeHandler?.SendMessage(msg); - if (success) - { - try - { - var fileName = msg; - Process process = new() - { - StartInfo = new ProcessStartInfo - { - FileName = "v2rayUpgrade", - Arguments = fileName.AppendQuotes(), - WorkingDirectory = Utils.StartupPath() - } - }; - process.Start(); - if (process.Id > 0) - { - MyAppExitAsync(false); - } - } - catch (Exception ex) - { - _noticeHandler?.SendMessage(ex.Message); - } - } - } - (new UpdateHandler()).CheckUpdateGuiN(_config, _updateUI, _config.guiItem.checkPreReleaseUpdate); - } - - private void CheckUpdateCore(ECoreType type, bool? preRelease) - { - void _updateUI(bool success, string msg) - { - _noticeHandler?.SendMessage(msg); - if (success) - { - CloseCore(); - - string fileName = Utils.GetTempPath(Utils.GetDownloadFileName(msg)); - string toPath = Utils.GetBinPath("", type.ToString()); - - if (fileName.Contains(".tar.gz")) - { - //It's too complicated to unzip. TODO - } - else if (fileName.Contains(".gz")) - { - FileManager.UncompressedFile(fileName, toPath, type.ToString()); - } - else - { - FileManager.ZipExtractToFile(fileName, toPath, _config.guiItem.ignoreGeoUpdateCore ? "geo" : ""); - } - - _noticeHandler?.SendMessage(ResUI.MsgUpdateV2rayCoreSuccessfullyMore); - - Reload(); - - _noticeHandler?.SendMessage(ResUI.MsgUpdateV2rayCoreSuccessfully); - - if (File.Exists(fileName)) - { - File.Delete(fileName); - } - } - } - (new UpdateHandler()).CheckUpdateCore(type, _config, _updateUI, preRelease ?? _config.guiItem.checkPreReleaseUpdate); - } - - private void CheckUpdateGeo() - { - (new UpdateHandler()).UpdateGeoFileAll(_config, UpdateTaskHandler); - } - - #endregion CheckUpdate - #region core job public void Reload() diff --git a/v2rayN/v2rayN/Views/CheckUpdateView.xaml b/v2rayN/v2rayN/Views/CheckUpdateView.xaml index fcd11a524f..fcbe255268 100644 --- a/v2rayN/v2rayN/Views/CheckUpdateView.xaml +++ b/v2rayN/v2rayN/Views/CheckUpdateView.xaml @@ -21,33 +21,26 @@ DockPanel.Dock="Bottom" Orientation="Horizontal"> -