diff --git a/Tanji.Infrastructure/Configuration/PlatformPaths.cs b/Tanji.Infrastructure/Configuration/PlatformPaths.cs index e80ad0d..bfe20e4 100644 --- a/Tanji.Infrastructure/Configuration/PlatformPaths.cs +++ b/Tanji.Infrastructure/Configuration/PlatformPaths.cs @@ -9,4 +9,5 @@ public readonly record struct PlatformPaths public readonly string RootPath { get; init; } public required string ClientPath { get; init; } public required string ExecutablePath { get; init; } + public required Int32 Version { get; init; } } \ No newline at end of file diff --git a/Tanji.Infrastructure/Configuration/PostConfigureTanjiOptions.cs b/Tanji.Infrastructure/Configuration/PostConfigureTanjiOptions.cs index 3bb388e..665d3bf 100644 --- a/Tanji.Infrastructure/Configuration/PostConfigureTanjiOptions.cs +++ b/Tanji.Infrastructure/Configuration/PostConfigureTanjiOptions.cs @@ -6,6 +6,7 @@ using Tanji.Infrastructure.Json; using Microsoft.Extensions.Options; +using System.Diagnostics; namespace Tanji.Infrastructure.Configuration; @@ -30,13 +31,25 @@ public void PostConfigure(string? name, TanjiOptions options) foreach (Installation installation in options.Versions.Installations) { + if (platformPaths.ContainsKey(installation.Platform)) + { + if(platformPaths[installation.Platform].Version < int.Parse(installation.Version)) + { + platformPaths.Remove(installation.Platform); + } + else + { + continue; + } + } + platformPaths.Add(installation.Platform, new PlatformPaths { Platform = installation.Platform, - RootPath = installation.Path, ClientPath = Path.Combine(installation.Path, PlatformConverter.ToClientName(installation.Platform)), - ExecutablePath = Path.Combine(installation.Path, PlatformConverter.ToExecutableName(installation.Platform)) + ExecutablePath = Path.Combine(installation.Path, PlatformConverter.ToExecutableName(installation.Platform)), + Version = int.Parse(installation.Version) }); } }