fix(ci): make launcher space guidance culture invariant
All checks were successful
CI / linux-portable (push) Successful in 3m23s
CI / windows-gate (push) Successful in 5m33s
CI / release (push) Successful in 2m8s

This commit is contained in:
Erik 2026-08-27 20:40:50 +02:00
parent cccae4169a
commit 45ba42a3a7
2 changed files with 35 additions and 21 deletions

View file

@ -1,6 +1,7 @@
using AcDream.Launcher.Core.Integrity; using AcDream.Launcher.Core.Integrity;
using AcDream.Launcher.Core.Launching; using AcDream.Launcher.Core.Launching;
using AcDream.Platform; using AcDream.Platform;
using System.Globalization;
namespace AcDream.Launcher.Core.Installation; namespace AcDream.Launcher.Core.Installation;
@ -326,9 +327,9 @@ public sealed class LauncherInstaller : ILauncherInstaller
{ {
string message = string message =
$"The optimized world-data rebuild needs at least " $"The optimized world-data rebuild needs at least "
+ $"{FullRebuildRequiredFreeBytes / (1024d * 1024d * 1024d):N1} GiB free " + $"{FormatGiB(FullRebuildRequiredFreeBytes)} GiB free "
+ $"beside the active package; only " + $"beside the active package; only "
+ $"{availableBytes / (1024d * 1024d * 1024d):N1} GiB is available."; + $"{FormatGiB(availableBytes)} GiB is available.";
Report(progress, LauncherInstallPhase.Failed, message); Report(progress, LauncherInstallPhase.Failed, message);
throw new LauncherInstallException(message); throw new LauncherInstallException(message);
} }
@ -636,6 +637,9 @@ public sealed class LauncherInstaller : ILauncherInstaller
.ConfigureAwait(false); .ConfigureAwait(false);
} }
private static string FormatGiB(long bytes) =>
(bytes / (1024d * 1024d * 1024d)).ToString("N1", CultureInfo.InvariantCulture);
public async Task<LauncherInstallResult> ApplyContentUpdateAsync( public async Task<LauncherInstallResult> ApplyContentUpdateAsync(
string datDirectory, string datDirectory,
int threads, int threads,

View file

@ -1,4 +1,5 @@
using System.Diagnostics; using System.Diagnostics;
using System.Globalization;
using System.Text.Json.Nodes; using System.Text.Json.Nodes;
using AcDream.Launcher.Core.Integrity; using AcDream.Launcher.Core.Integrity;
using AcDream.Launcher.Core.Installation; using AcDream.Launcher.Core.Installation;
@ -150,28 +151,37 @@ public sealed class LauncherInstallerTests : IDisposable
[Fact] [Fact]
public async Task InsufficientFreeSpaceStopsBeforeBakeAndReportsExactRequirement() public async Task InsufficientFreeSpaceStopsBeforeBakeAndReportsExactRequirement()
{ {
bool childStarted = false; CultureInfo originalCulture = CultureInfo.CurrentCulture;
var runner = new FakeBakeProcessRunner((_, _, _) => CultureInfo.CurrentCulture = CultureInfo.GetCultureInfo("sv-SE");
try
{ {
childStarted = true; bool childStarted = false;
return Task.FromResult(new BakeProcessResult(0, string.Empty)); var runner = new FakeBakeProcessRunner((_, _, _) =>
}); {
var installer = new LauncherInstaller( childStarted = true;
_paths, return Task.FromResult(new BakeProcessResult(0, string.Empty));
_bakeExecutable, });
processRunner: runner, var installer = new LauncherInstaller(
availableFreeSpace: _ => _paths,
LauncherInstaller.FullRebuildRequiredFreeBytes - 1); _bakeExecutable,
processRunner: runner,
availableFreeSpace: _ =>
LauncherInstaller.FullRebuildRequiredFreeBytes - 1);
LauncherInstallException error = await Assert.ThrowsAsync<LauncherInstallException>( LauncherInstallException error = await Assert.ThrowsAsync<LauncherInstallException>(
() => installer.InstallAsync(_dats, threads: 2)); () => installer.InstallAsync(_dats, threads: 2));
Assert.False(childStarted); Assert.False(childStarted);
Assert.Contains("2.0 GiB", error.Message, StringComparison.Ordinal); Assert.Contains("2.0 GiB", error.Message, StringComparison.Ordinal);
Assert.Contains("active package", error.Message, StringComparison.Ordinal); Assert.Contains("active package", error.Message, StringComparison.Ordinal);
Assert.False(File.Exists( Assert.False(File.Exists(
LauncherInstaller.GetFullRebuildCandidatePath( LauncherInstaller.GetFullRebuildCandidatePath(
Path.Combine(_paths.DataDirectory, "pak", "acdream.pak")))); Path.Combine(_paths.DataDirectory, "pak", "acdream.pak"))));
}
finally
{
CultureInfo.CurrentCulture = originalCulture;
}
} }
[Fact] [Fact]