Skip to content

Commit

Permalink
Fixed issue with running ModAssistant.old.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
Assistant committed Feb 27, 2020
1 parent 97d98b8 commit eb2ab28
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions ModAssistant/Classes/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Updater
private static Version CurrentVersion;
private static Version LatestVersion;
private static bool NeedsUpdate = false;
private static string NewExe = Path.Combine(Path.GetDirectoryName(Utils.ExePath), "ModAssistant.exe");

public static async Task<bool> CheckForUpdate()
{
Expand All @@ -30,6 +31,7 @@ public static async Task<bool> CheckForUpdate()

public static async Task Run()
{
if (Path.GetFileName(Utils.ExePath).Equals("ModAssistant.old.exe")) RunNew();
try
{
NeedsUpdate = await CheckForUpdate();
Expand All @@ -44,9 +46,7 @@ public static async Task Run()

public static async Task StartUpdate()
{
string Directory = Path.GetDirectoryName(Utils.ExePath);
string OldExe = Path.Combine(Directory, "ModAssistant.old.exe");

string OldExe = Path.Combine(Path.GetDirectoryName(Utils.ExePath), "ModAssistant.old.exe");
string DownloadLink = null;

foreach (Update.Asset asset in LatestUpdate.assets)
Expand All @@ -70,14 +70,16 @@ public static async Task StartUpdate()

File.Move(Utils.ExePath, OldExe);

await Utils.Download(DownloadLink, Utils.ExePath);
Process.Start(Utils.ExePath);
App.Current.Shutdown();

await Utils.Download(DownloadLink, NewExe);
RunNew();
}

}

private static void RunNew()
{
Process.Start(NewExe);
Application.Current.Dispatcher.Invoke(() => { Application.Current.Shutdown(); });
}
}

public class Update
Expand Down

0 comments on commit eb2ab28

Please sign in to comment.