Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Instantiate UpdateManager after install directory has been set up to …
Browse files Browse the repository at this point in the history
…prevent locking
  • Loading branch information
caesay committed Jun 8, 2022
1 parent 34fbcad commit 0e8db6f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Update.Windows/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Squirrel.SimpleSplat;
using Squirrel.SimpleSplat;
using Squirrel.Json;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -256,14 +256,12 @@ static async Task Install(bool silentInstall, ProgressSource progressSource, str
.First().PackageName;

var rootAppDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ourAppName);
var appDesc = new AppDescWindows(rootAppDir, ourAppName, true);
using var mgr = new UpdateManager(new SimpleFileSource(sourceDi), appDesc);


Log.Info("About to install to: " + rootAppDir);
if (Directory.Exists(rootAppDir)) {
Log.Warn("Install path {0} already exists, burning it to the ground", rootAppDir);

mgr.KillAllExecutablesBelongingToPackage();
PlatformUtil.KillProcessesInDirectory(rootAppDir);
await Task.Delay(500);

Log.ErrorIfThrows(() => Utility.Retry(() => Utility.DeleteFileOrDirectoryHard(rootAppDir, throwOnFailure: true, renameFirst: true)),
Expand All @@ -279,6 +277,8 @@ static async Task Install(bool silentInstall, ProgressSource progressSource, str
Log.ErrorIfThrows(() => File.Copy(SquirrelRuntimeInfo.EntryExePath, updateTarget, true),
"Failed to copy Update.exe to " + updateTarget);

var appDesc = new AppDescWindows(rootAppDir, ourAppName, true);
using var mgr = new UpdateManager(new SimpleFileSource(sourceDi), appDesc);
await mgr.FullInstall(silentInstall, progressSource.Raise);

using var rk = await Log.ErrorIfThrows(() => mgr.CreateUninstallerRegistryEntry(),
Expand Down

0 comments on commit 0e8db6f

Please sign in to comment.