Skip to content

Commit

Permalink
add autostart removal on uninstallation
Browse files Browse the repository at this point in the history
  • Loading branch information
aspriddell committed Nov 20, 2024
1 parent c39da53 commit f462d12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion DragonFruit.OnionFruit.Windows/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public static class Program
public static void Main(string[] args)
{
HandleSecondInstance();
VelopackApp.Build().Run();

VelopackApp.Build().WithBeforeUninstallFastCallback(_ => PerformRemovalCleanup()).Run();

// FluentAvalonia needs Windows 10.0.14393.0 (Anniversary Update) or later
// see https://github.com/amwx/FluentAvalonia/issues/212
Expand Down Expand Up @@ -208,4 +209,12 @@ private static void PerformShutdown(object sender, UnhandledExceptionEventArgs e
// shutdown any ongoing session
_host?.Services.GetService<TorSession>().StopSession().AsTask().Wait();
}

private static void PerformRemovalCleanup()
{
using (var startupManager = new StartupLaunchService(null, null))
{
startupManager.SetStartupState(false);
}
}
}
4 changes: 2 additions & 2 deletions DragonFruit.OnionFruit.Windows/StartupLaunchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public StartupLaunchService(IOnionFruitUpdater updater, string[] launchArgs)
_startupCollectionKey = null;
}

InstanceLaunchedByStartupService = launchArgs.Any(x => x.Equals(StartupAppArgs, StringComparison.OrdinalIgnoreCase));
InstanceLaunchedByStartupService = launchArgs?.Any(x => x.Equals(StartupAppArgs, StringComparison.OrdinalIgnoreCase)) == true;
}

public bool InstanceLaunchedByStartupService { get; }
Expand Down Expand Up @@ -71,7 +71,7 @@ public StartupLaunchState SetStartupState(bool enabled)
private StartupLaunchState GetStartupStateImpl()
{
#if !DEBUG
if (!_updater.IsInstalled)
if (_updater?.IsInstalled != true)
{
return StartupLaunchState.Blocked;
}
Expand Down

0 comments on commit f462d12

Please sign in to comment.