mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Implement FullUninstall
This commit is contained in:
@@ -42,22 +42,19 @@ namespace Squirrel
|
|||||||
progress(100);
|
progress(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task FullUninstall(Version version = null)
|
public async Task FullUninstall()
|
||||||
{
|
{
|
||||||
version = version ?? new Version(255, 255, 255, 255);
|
var currentRelease = getReleases().MaxBy(x => x.Name.ToVersion()).FirstOrDefault();
|
||||||
this.Log().Info("Uninstalling version '{0}'", version);
|
|
||||||
|
|
||||||
// find all the old releases (and this one)
|
if (currentRelease.Exists)
|
||||||
var directoriesToDelete = getOldReleases(version)
|
{
|
||||||
.Concat(new [] { getDirectoryForRelease(version) })
|
var version = currentRelease.Name.ToVersion();
|
||||||
.Where(d => d.Exists)
|
|
||||||
.Select(d => d.FullName);
|
|
||||||
|
|
||||||
await directoriesToDelete.ForEachAsync(x => Utility.DeleteDirectoryWithFallbackToNextReboot(x));
|
await SquirrelAwareExecutableDetector.GetAllSquirrelAwareApps(currentRelease.FullName)
|
||||||
|
.ForEachAsync(exe => Utility.InvokeProcessAsync(exe, String.Format("/squirrel-uninstall {0}", version)), 1);
|
||||||
if (!getReleases().Any()) {
|
|
||||||
await Utility.DeleteDirectoryWithFallbackToNextReboot(rootAppDirectory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Utility.DeleteDirectoryWithFallbackToNextReboot(rootAppDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task installPackageToAppDir(UpdateInfo updateInfo, ReleaseEntry release)
|
async Task installPackageToAppDir(UpdateInfo updateInfo, ReleaseEntry release)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using Splat;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Squirrel
|
namespace Squirrel
|
||||||
{
|
{
|
||||||
@@ -98,6 +99,24 @@ namespace Squirrel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Task<int> InvokeProcessAsync(string fileName, string arguments)
|
||||||
|
{
|
||||||
|
var psi = new ProcessStartInfo(fileName, arguments);
|
||||||
|
psi.UseShellExecute = false;
|
||||||
|
psi.WindowStyle = ProcessWindowStyle.Hidden;
|
||||||
|
psi.ErrorDialog = false;
|
||||||
|
|
||||||
|
return InvokeProcessAsync(psi);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<int> InvokeProcessAsync(ProcessStartInfo psi)
|
||||||
|
{
|
||||||
|
var pi = Process.Start(psi);
|
||||||
|
|
||||||
|
await Task.Run(() => pi.WaitForExit());
|
||||||
|
return pi.ExitCode;
|
||||||
|
}
|
||||||
|
|
||||||
public static Task ForEachAsync<T>(this IEnumerable<T> source, Action<T> body, int degreeOfParallelism = 4)
|
public static Task ForEachAsync<T>(this IEnumerable<T> source, Action<T> body, int degreeOfParallelism = 4)
|
||||||
{
|
{
|
||||||
return ForEachAsync(source, x => Task.Run(() => body(x)), degreeOfParallelism);
|
return ForEachAsync(source, x => Task.Run(() => body(x)), degreeOfParallelism);
|
||||||
|
|||||||
Reference in New Issue
Block a user