diff --git a/src/Launcher.Core/SetupGuide.cs b/src/Launcher.Core/SetupGuide.cs index 8dd8d58..1701847 100644 --- a/src/Launcher.Core/SetupGuide.cs +++ b/src/Launcher.Core/SetupGuide.cs @@ -201,7 +201,7 @@ static async Task RemovePartialClone(string target) /// the client tables from client.db and live.ps1 extracts only what they still read. public static bool ExtractsForServers(string checkout) { - try { return Regex.IsMatch(File.ReadAllText(Path.Combine(checkout, "scripts", "dev", "extract-data.ps1")), @"\[switch\]\$Servers", RegexOptions.IgnoreCase); } + try { return Regex.IsMatch(File.ReadAllText(Path.Combine(checkout, "scripts", "dev", "extract-data.ps1")), @"\[switch\]\$Servers\b", RegexOptions.IgnoreCase); } catch (Exception e) when (e is IOException or UnauthorizedAccessException) { return false; } } diff --git a/tests/Launcher.Checks/SetupChecks.cs b/tests/Launcher.Checks/SetupChecks.cs index bb951b5..6324592 100644 --- a/tests/Launcher.Checks/SetupChecks.cs +++ b/tests/Launcher.Checks/SetupChecks.cs @@ -15,6 +15,7 @@ public static async Task RunAsync(string fixture, Action check) await LinksAsync(root, check); await SequenceAsync(check); await CloneAsync(root, check); + ExtractScope(root, check); check(Prerequisites.HasSdk("8.0.427 [C:\\sdk]\n10.0.403 [C:\\sdk]\n") && !Prerequisites.HasSdk("9.0.320 [C:\\sdk]\n"), "only a .NET 10 SDK counts"); check(PythonLookup.VersionOf("Python 3.12.4") == new Version(3, 12, 4) && PythonLookup.VersionOf("Python 3.9.0b1") == new Version(3, 9, 0) && PythonLookup.VersionOf("Python was not found; run without arguments to install from the Microsoft Store") is null, @@ -52,6 +53,23 @@ static string Client(string root, string name, params (string File, int Bytes)[] return folder; } + /// Setup extracts only what the servers read when the checkout's extract-data.ps1 takes -Servers. + static void ExtractScope(string root, Action check) + { + string Checkout(string name, string param) + { + string folder = Path.Combine(root, name); + Directory.CreateDirectory(Path.Combine(folder, "scripts", "dev")); + File.WriteAllText(Path.Combine(folder, "scripts", "dev", "extract-data.ps1"), $"# extracts game data\r\nparam({param})\r\n"); + return folder; + } + check(SetupSequence.ExtractsForServers(Checkout("split", "[switch]$Force, [string[]]$Only = @(), [switch]$List, [string]$ExportManifest, [switch]$Servers")), + "a checkout whose extract-data.ps1 takes -Servers extracts only what the servers read"); + check(!SetupSequence.ExtractsForServers(Checkout("before-split", "[switch]$Force, [string[]]$Only = @(), [switch]$List, [string]$ServersList")), + "a checkout from before the split, or a longer name that starts with Servers, extracts everything"); + check(!SetupSequence.ExtractsForServers(Path.Combine(root, "no-checkout")), "no extract-data.ps1 extracts everything"); + } + static void Classify(string root, Action check) { string standalone = Client(root, "standalone", ("Content.ggpk", 10), ("PathOfExile.exe", 10));