From f0cfe6d0c1f1a38ed0be3de03b67376ccf8d51be Mon Sep 17 00:00:00 2001 From: Damien Date: Mon, 16 Sep 2024 18:50:51 +0200 Subject: [PATCH] [modgen] ajustements encore si pas d'internet --- TopModel.Generator/Program.cs | 2 +- TopModel.Utils/NugetUtils.cs | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/TopModel.Generator/Program.cs b/TopModel.Generator/Program.cs index fc65271f..6cf5e7a6 100644 --- a/TopModel.Generator/Program.cs +++ b/TopModel.Generator/Program.cs @@ -339,7 +339,7 @@ void HandleFile(FileInfo file) if (!topModelLock.Modules.TryGetValue(configKey, out var moduleVersion)) { - moduleVersion = await NugetUtils.GetLatestVersionAsync(fullModuleName); + moduleVersion = await NugetUtils.GetLatestVersionAsync(fullModuleName, forceCheck: true); if (moduleVersion == null) { diff --git a/TopModel.Utils/NugetUtils.cs b/TopModel.Utils/NugetUtils.cs index d1e073d5..acac2d19 100644 --- a/TopModel.Utils/NugetUtils.cs +++ b/TopModel.Utils/NugetUtils.cs @@ -45,13 +45,8 @@ public static async Task DownloadPackageAsync(string id, s return new PackageArchiveReader(packageStream); } - public static async Task GetLatestVersionAsync(string id) + public static async Task GetLatestVersionAsync(string id, bool forceCheck = false) { - if (cantCheckVersion) - { - return null; - } - if (Versions.TryGetValue(id, out var cachedVersion)) { if (cachedVersion.CheckDate.AddHours(6) < DateTime.UtcNow) @@ -62,13 +57,20 @@ public static async Task DownloadPackageAsync(string id, s { if (cachedVersion.Version == null) { - return null; + cantCheckVersion = true; + } + else + { + return new TopModelLockModule { Version = cachedVersion.Version }; } - - return new TopModelLockModule { Version = cachedVersion.Version }; } } + if (cantCheckVersion && !forceCheck) + { + return null; + } + try { var nugetResource = await GetNugetResourceAsync();