From c677132662514d0c20f218a9ad514cf4b864d8d6 Mon Sep 17 00:00:00 2001 From: Darwin Baker <51175243+DarwinBaker@users.noreply.github.com> Date: Thu, 15 Jul 2021 02:55:27 -0400 Subject: [PATCH] Fix updater file deletion issue --- AAUpdate/Updater.cs | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/AAUpdate/Updater.cs b/AAUpdate/Updater.cs index 95eeecb1..236036e4 100644 --- a/AAUpdate/Updater.cs +++ b/AAUpdate/Updater.cs @@ -1,10 +1,11 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; using System.Net; +using System.Windows.Forms; namespace AAUpdate { @@ -174,7 +175,7 @@ private void ExtractLatestZip() StatusChanged(STATUS_2, "Compiling file lists..."); //populate lists of files from source and destination to compare diffs - OldFiles = GetFilesRecursive(Destination); + OldFiles = GetFilesRecursive(new DirectoryInfo(Path.Combine(Destination.FullName, "assets"))); NewFiles = GetFilesRecursive(Source); } @@ -212,16 +213,35 @@ private void MirrorSourceToDestination() { StatusChanged(STATUS_2, "Deleting depricated files..."); int processed = 0; + + try + { + File.Delete("AATool.exe"); + } + catch { } + + try + { + File.Delete("AAUpdate.exe"); + } + catch { } + + try + { + File.Delete("VersionHistory.txt"); + } + catch { } + foreach (var file in OldFiles) { processed++; ProgressChanged(PROGRESS_2, (processed, OldFiles.Count)); //if file from current install isn't in latest release delete it - if (!NewFiles.Contains(file)) + if (!NewFiles.Contains(Path.Combine("assets", file))) { StatusChanged(STATUS_3, file); - File.Delete(Path.Combine(Destination.FullName, file)); + File.Delete(Path.Combine(Destination.FullName, "assets", file)); } } //clear out any empty directories