Skip to content

Commit cd69a2d

Browse files
authored
Merge pull request #192 from rankynbass/fix-aria2-closing
fix: aria2 will pause and close on exit
2 parents 980f3b9 + bf77d70 commit cd69a2d

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/XIVLauncher.Core/Components/MainPage/MainPage.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,9 +1005,9 @@ private async Task<bool> TryHandlePatchAsync(Repository repository, PatchListEnt
10051005
}
10061006

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

10131013
/*
@@ -1039,18 +1039,18 @@ void UpdatePatchStatus()
10391039
{
10401040
Thread.Sleep(30);
10411041

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

1046-
App.LoadingPage.Progress = patcher.CurrentInstallIndex / (float)patcher.Downloads.Count;
1046+
App.LoadingPage.Progress = Program.Patcher.CurrentInstallIndex / (float)Program.Patcher.Downloads.Count;
10471047
}
10481048
}
10491049

10501050
try
10511051
{
10521052
var aria2LogFile = new FileInfo(Path.Combine(App.Storage.GetFolder("logs").FullName, "launcher.log"));
1053-
await patcher.PatchAsync(aria2LogFile, false).ConfigureAwait(false);
1053+
await Program.Patcher.PatchAsync(aria2LogFile, false).ConfigureAwait(false);
10541054
}
10551055
finally
10561056
{

src/XIVLauncher.Core/Program.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
using XIVLauncher.Common;
1616
using XIVLauncher.Common.Dalamud;
17+
using XIVLauncher.Common.Game.Patch;
1718
using XIVLauncher.Common.Game.Patch.Acquisition;
1819
using XIVLauncher.Common.PlatformAbstractions;
1920
using XIVLauncher.Common.Support;
@@ -50,6 +51,7 @@ sealed class Program
5051
{
5152
Timeout = TimeSpan.FromSeconds(5)
5253
};
54+
public static PatchManager Patcher { get; set; } = null!;
5355

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

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

360-
HttpClient.Dispose();
361362
// Clean up Veldrid resources
362363
gd.WaitForIdle();
363364
bindings.Dispose();
364365
cl.Dispose();
365366
gd.Dispose();
367+
368+
HttpClient.Dispose();
369+
370+
if (Patcher is not null)
371+
{
372+
Patcher.CancelAllDownloads();
373+
Task.Run(async() =>
374+
{
375+
await PatchManager.UnInitializeAcquisition().ConfigureAwait(false);
376+
Environment.Exit(0);
377+
});
378+
}
366379
}
367380

368381
public static void CreateCompatToolsInstance()

0 commit comments

Comments
 (0)