Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: aria2 will pause and close on exit #192

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/XIVLauncher.Core/Components/MainPage/MainPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,9 +1005,9 @@ private async Task<bool> TryHandlePatchAsync(Repository repository, PatchListEnt
}

using var installer = new PatchInstaller(App.Settings.KeepPatches ?? false);
var patcher = new PatchManager(App.Settings.PatchAcquisitionMethod ?? AcquisitionMethod.Aria, App.Settings.PatchSpeedLimit, repository, pendingPatches, App.Settings.GamePath,
Program.Patcher = new PatchManager(App.Settings.PatchAcquisitionMethod ?? AcquisitionMethod.Aria, App.Settings.PatchSpeedLimit, repository, pendingPatches, App.Settings.GamePath,
App.Settings.PatchPath, installer, App.Launcher, sid);
patcher.OnFail += PatcherOnFail;
Program.Patcher.OnFail += PatcherOnFail;
installer.OnFail += this.InstallerOnFail;

/*
Expand Down Expand Up @@ -1039,18 +1039,18 @@ void UpdatePatchStatus()
{
Thread.Sleep(30);

App.LoadingPage.Line2 = string.Format("Working on {0}/{1}", patcher.CurrentInstallIndex, patcher.Downloads.Count);
App.LoadingPage.Line3 = string.Format("{0} left to download at {1}/s", ApiHelpers.BytesToString(patcher.AllDownloadsLength < 0 ? 0 : patcher.AllDownloadsLength),
ApiHelpers.BytesToString(patcher.Speeds.Sum()));
App.LoadingPage.Line2 = string.Format("Working on {0}/{1}", Program.Patcher.CurrentInstallIndex, Program.Patcher.Downloads.Count);
App.LoadingPage.Line3 = string.Format("{0} left to download at {1}/s", ApiHelpers.BytesToString(Program.Patcher.AllDownloadsLength < 0 ? 0 : Program.Patcher.AllDownloadsLength),
ApiHelpers.BytesToString(Program.Patcher.Speeds.Sum()));

App.LoadingPage.Progress = patcher.CurrentInstallIndex / (float)patcher.Downloads.Count;
App.LoadingPage.Progress = Program.Patcher.CurrentInstallIndex / (float)Program.Patcher.Downloads.Count;
}
}

try
{
var aria2LogFile = new FileInfo(Path.Combine(App.Storage.GetFolder("logs").FullName, "launcher.log"));
await patcher.PatchAsync(aria2LogFile, false).ConfigureAwait(false);
await Program.Patcher.PatchAsync(aria2LogFile, false).ConfigureAwait(false);
}
finally
{
Expand Down
15 changes: 14 additions & 1 deletion src/XIVLauncher.Core/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using XIVLauncher.Common;
using XIVLauncher.Common.Dalamud;
using XIVLauncher.Common.Game.Patch;
using XIVLauncher.Common.Game.Patch.Acquisition;
using XIVLauncher.Common.PlatformAbstractions;
using XIVLauncher.Common.Support;
Expand Down Expand Up @@ -50,6 +51,7 @@ sealed class Program
{
Timeout = TimeSpan.FromSeconds(5)
};
public static PatchManager Patcher { get; set; } = null!;

private static readonly Vector3 ClearColor = new(0.1f, 0.1f, 0.1f);

Expand Down Expand Up @@ -357,12 +359,23 @@ private static void Main(string[] args)
gd.SwapBuffers(gd.MainSwapchain);
}

HttpClient.Dispose();
// Clean up Veldrid resources
gd.WaitForIdle();
bindings.Dispose();
cl.Dispose();
gd.Dispose();

HttpClient.Dispose();

if (Patcher is not null)
{
Patcher.CancelAllDownloads();
Task.Run(async() =>
{
await PatchManager.UnInitializeAcquisition().ConfigureAwait(false);
Environment.Exit(0);
});
}
}

public static void CreateCompatToolsInstance()
Expand Down
Loading