Skip to content

Commit

Permalink
add install callback
Browse files Browse the repository at this point in the history
  • Loading branch information
aspriddell committed Nov 20, 2024
1 parent f462d12 commit c814469
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions DragonFruit.OnionFruit.Windows/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ public static void Main(string[] args)
{
HandleSecondInstance();

VelopackApp.Build().WithBeforeUninstallFastCallback(_ => PerformRemovalCleanup()).Run();
VelopackApp.Build()
.WithAfterInstallFastCallback(_ => PerformInstallationSetup())
.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 @@ -210,11 +213,20 @@ private static void PerformShutdown(object sender, UnhandledExceptionEventArgs e
_host?.Services.GetService<TorSession>().StopSession().AsTask().Wait();
}

private static void PerformRemovalCleanup()
private static void PerformInstallationSetup()
{
using (var startupManager = new StartupLaunchService(null, null))
using var startupManager = new StartupLaunchService(null, null);

// migrate any old startup settings to the new system
if (startupManager.CurrentStartupState == StartupLaunchState.EnabledInvalid)
{
startupManager.SetStartupState(false);
startupManager.SetStartupState(true);
}
}

private static void PerformRemovalCleanup()
{
using var startupManager = new StartupLaunchService(null, null);
startupManager.SetStartupState(false);
}
}

0 comments on commit c814469

Please sign in to comment.