From c6e65b4e24e406bd35912a869ada0c93f9f01ae4 Mon Sep 17 00:00:00 2001 From: bao-qian Date: Mon, 6 Mar 2017 00:25:17 +0000 Subject: [PATCH] test --- Deploy/local_build.ps1 | 4 ++++ Wox.Core/Updater.cs | 34 +++++++++++++++++++++++++++++++--- Wox/App.xaml.cs | 2 +- 3 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 Deploy/local_build.ps1 diff --git a/Deploy/local_build.ps1 b/Deploy/local_build.ps1 new file mode 100644 index 0000000000..9dd7582b19 --- /dev/null +++ b/Deploy/local_build.ps1 @@ -0,0 +1,4 @@ +New-Alias nuget.exe ".\packages\NuGet.CommandLine.*\tools\NuGet.exe" +$env:APPVEYOR_BUILD_FOLDER = Convert-Path . +$env:APPVEYOR_BUILD_VERSION = "1.2.0" +& .\Deploy\squirrel_installer.ps1 \ No newline at end of file diff --git a/Wox.Core/Updater.cs b/Wox.Core/Updater.cs index e6ea1c7933..a39cab0df9 100644 --- a/Wox.Core/Updater.cs +++ b/Wox.Core/Updater.cs @@ -4,9 +4,12 @@ using System.Net; using System.Net.Http; using System.Net.Sockets; using System.Threading.Tasks; +using System.Windows; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Squirrel; +using Wox.Core.Resource; +using Wox.Infrastructure; using Wox.Infrastructure.Http; using Wox.Infrastructure.Logger; @@ -22,11 +25,28 @@ namespace Wox.Core try { - const string url = Infrastructure.Constant.Github; - // todo 5/9 the return value of UpdateApp() is NULL, fucking useless! + const string url = Constant.Github; + // UpdateApp() will return value only if the app is squirrel installed using (var m = await UpdateManager.GitHubUpdateManager(url, urlDownloader: d)) { - await m.UpdateApp(); + var e = await m.CheckForUpdate(); + var fe = e.FutureReleaseEntry; + var ce = e.CurrentlyInstalledVersion; + if (fe.Version > ce.Version) + { + var t = NewVersinoTips(fe.Version.ToString()); + MessageBox.Show(t); + + await m.DownloadReleases(e.ReleasesToApply); + await m.ApplyReleases(e); + await m.CreateUninstallerRegistryEntry(); + + Log.Info($"|Updater.UpdateApp|TEST <{e.Formatted()}>"); + Log.Info($"|Updater.UpdateApp|TEST <{fe.Formatted()}>"); + Log.Info($"|Updater.UpdateApp|TEST <{ce.Formatted()}>"); + Log.Info($"|Updater.UpdateApp|TEST <{e.ReleasesToApply.Formatted()}>"); + Log.Info($"|Updater.UpdateApp|TEST <{t.Formatted()}>"); + } } } catch (Exception e) when (e is HttpRequestException || e is WebException || e is SocketException) @@ -99,5 +119,13 @@ namespace Wox.Core var newVersion = version.Replace("v", ".").Replace(".", "").Replace("*", ""); return int.Parse(newVersion); } + + public static string NewVersinoTips(string version) + { + var translater = InternationalizationManager.Instance; + var tips = string.Format(translater.GetTranslation("newVersionTips"), version); + return tips; + } + } } diff --git a/Wox/App.xaml.cs b/Wox/App.xaml.cs index 012f2be7e9..14a798a6a7 100644 --- a/Wox/App.xaml.cs +++ b/Wox/App.xaml.cs @@ -95,7 +95,7 @@ namespace Wox } } - [Conditional("RELEASE")] + //[Conditional("RELEASE")] private void AutoUpdates() { Task.Run(async () =>