diff --git a/LancachePrefill.Common b/LancachePrefill.Common index 58a8b83e..972a30cd 160000 --- a/LancachePrefill.Common +++ b/LancachePrefill.Common @@ -1 +1 @@ -Subproject commit 58a8b83eebf9f335ff766b45468b4871380fed1c +Subproject commit 972a30cdcf7794020e4eece6f91d7ae41983cbc4 diff --git a/SteamPrefill/Models/DownloadArguments.cs b/SteamPrefill/Models/DownloadArguments.cs index a43b6ebf..239114b2 100644 --- a/SteamPrefill/Models/DownloadArguments.cs +++ b/SteamPrefill/Models/DownloadArguments.cs @@ -2,6 +2,8 @@ { public sealed class DownloadArguments { + private int _maxConcurrentRequests = 30; + /// /// When set to true, always run the download, regardless of if the app has been previously downloaded. /// @@ -19,7 +21,19 @@ public sealed class DownloadArguments /// The default of 30 was found to be a good middle ground for maximum throughput. It also minimizes the potential for SteamPrefill to /// choke out any other downloads on the network, without having to require users setup QoS themselves. /// - public int MaxConcurrentRequests { get; set; } = 30; + public int MaxConcurrentRequests + { + get + { + //TODO I don't like how this is using a static variable like this, because nothing else in this class is like this. Consider removing this later once its no longer used for debugging. + if (AppConfig.MaxConcurrencyOverride != null) + { + return AppConfig.MaxConcurrencyOverride.Value; + } + return _maxConcurrentRequests; + } + set => _maxConcurrentRequests = value; + } /// /// Determines which Operating System specific depots should be included in the download. diff --git a/SteamPrefill/Program.cs b/SteamPrefill/Program.cs index 74facb03..4a70ad81 100644 --- a/SteamPrefill/Program.cs +++ b/SteamPrefill/Program.cs @@ -6,14 +6,16 @@ public static async Task Main() { try { - // Checking to see if the user double clicked the exe in Windows, and display a message on how to use the app + // Checking to see if the user double-clicked the exe in Windows, and display a message on how to use the app OperatingSystemUtils.DetectDoubleClickOnWindows("SteamPrefill"); var cliArgs = ParseHiddenFlags(); - var description = "Automatically fills a Lancache with games from Steam, so that subsequent downloads will be \n" + - " served from the Lancache, improving speeds and reducing load on your internet connection. \n" + - "\n" + - " Start by selecting apps for prefill with the 'select-apps' command, then start the prefill using 'prefill'"; + var description = """ + Automatically fills a Lancache with games from Steam, so that subsequent downloads will be + served from the Lancache, improving speeds and reducing load on your internet connection. + + Start by selecting apps for prefill with the 'select-apps' command, then start the prefill using 'prefill' + """; return await new CliApplicationBuilder() .AddCommandsFromThisAssembly() @@ -101,6 +103,17 @@ private static List ParseHiddenFlags() args.Remove(id); } + if (args.Any(e => e.Contains("--max-threads"))) + { + var flagIndex = args.IndexOf("--max-threads"); + var count = args[flagIndex + 1]; + AppConfig.MaxConcurrencyOverride = int.Parse(count); + + AnsiConsole.Console.LogMarkupLine($"Using {LightYellow("--max-threads")} flag. Will download using at most {Magenta(count)} threads"); + args.Remove("--max-threads"); + args.Remove(count); + } + // Adding some formatting to logging to make it more readable + clear that these flags are enabled if (AppConfig.DebugLogs || AppConfig.SkipDownloads || AppConfig.NoLocalCache) { diff --git a/SteamPrefill/Settings/AppConfig.cs b/SteamPrefill/Settings/AppConfig.cs index 27d1932b..6ff91828 100644 --- a/SteamPrefill/Settings/AppConfig.cs +++ b/SteamPrefill/Settings/AppConfig.cs @@ -92,6 +92,8 @@ public static bool DebugLogs public static uint? CellIdOverride { get; set; } + public static int? MaxConcurrencyOverride { get; set; } + #endregion } } \ No newline at end of file