From dc2ba1232243bbdc423d19a094a3677b1a872fc1 Mon Sep 17 00:00:00 2001 From: Adrian Mateoaea Date: Fri, 20 Mar 2020 16:44:57 +0200 Subject: [PATCH] Fix auto updater cached file after update --- Luna/Properties/AssemblyInfo.cs | 4 ++-- Luna/Utils/AutoFileSaver.cs | 12 ++++++++++++ Luna/Utils/AutoUpdater.cs | 10 +++++++++- Luna/Windows/UpdateWindow.xaml | 8 ++------ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Luna/Properties/AssemblyInfo.cs b/Luna/Properties/AssemblyInfo.cs index 8ed7f8a..62f4580 100644 --- a/Luna/Properties/AssemblyInfo.cs +++ b/Luna/Properties/AssemblyInfo.cs @@ -49,6 +49,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.1.0")] -[assembly: AssemblyFileVersion("1.1.1.0")] +[assembly: AssemblyVersion("1.1.2.0")] +[assembly: AssemblyFileVersion("1.1.2.0")] [assembly: Guid("7FDBD0F5-0E11-4048-8C62-A5F64BB878AF")] diff --git a/Luna/Utils/AutoFileSaver.cs b/Luna/Utils/AutoFileSaver.cs index 6c8e9b5..2ab67f9 100644 --- a/Luna/Utils/AutoFileSaver.cs +++ b/Luna/Utils/AutoFileSaver.cs @@ -62,6 +62,18 @@ public void ReloadFromDisk() } } + public void DeleteFromDisk() + { + try + { + File.Delete(Path); + } + catch (Exception ex) + { + Logger.Error(ex.Message); + } + } + private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (ReadOnly) diff --git a/Luna/Utils/AutoUpdater.cs b/Luna/Utils/AutoUpdater.cs index df8424e..94d57b2 100644 --- a/Luna/Utils/AutoUpdater.cs +++ b/Luna/Utils/AutoUpdater.cs @@ -1,6 +1,7 @@ using Luna.Models; using Luna.Utils.Logger; using System; +using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; @@ -55,7 +56,9 @@ public AutoUpdater(bool autoUpdate = false, bool noStart = false) AutoUpdate = autoUpdate; NoStart = noStart; - if (Model.Status == UpdateStatus.Checking || Model.Status == UpdateStatus.Downloading || Model.Status == UpdateStatus.Error) + List resetStatuses = new List() { UpdateStatus.Checking, UpdateStatus.Downloading, UpdateStatus.Error }; + + if (resetStatuses.Contains(Model.Status)) { Model.Status = UpdateStatus.None; } @@ -169,9 +172,14 @@ public void InstallUpdate() if (!File.Exists(Model.DownloadPath)) { Logger.Warning("Update file was not found at '{0}'", Model.DownloadPath); + + Model.Status = UpdateStatus.Error; + return; } + _autoSaver.DeleteFromDisk(); + Logger.Info("Staring update file at '{0}'", Model.DownloadPath); try diff --git a/Luna/Windows/UpdateWindow.xaml b/Luna/Windows/UpdateWindow.xaml index c8590b6..3ea1965 100644 --- a/Luna/Windows/UpdateWindow.xaml +++ b/Luna/Windows/UpdateWindow.xaml @@ -27,11 +27,7 @@ - + @@ -66,7 +62,7 @@ -