Skip to content

Commit

Permalink
[modgen] ajustements encore si pas d'internet
Browse files Browse the repository at this point in the history
  • Loading branch information
JabX committed Sep 16, 2024
1 parent dc00ef6 commit f0cfe6d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion TopModel.Generator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
20 changes: 11 additions & 9 deletions TopModel.Utils/NugetUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,8 @@ public static async Task<PackageArchiveReader> DownloadPackageAsync(string id, s
return new PackageArchiveReader(packageStream);
}

public static async Task<TopModelLockModule?> GetLatestVersionAsync(string id)
public static async Task<TopModelLockModule?> GetLatestVersionAsync(string id, bool forceCheck = false)
{
if (cantCheckVersion)
{
return null;
}

if (Versions.TryGetValue(id, out var cachedVersion))
{
if (cachedVersion.CheckDate.AddHours(6) < DateTime.UtcNow)
Expand All @@ -62,13 +57,20 @@ public static async Task<PackageArchiveReader> 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();
Expand Down

0 comments on commit f0cfe6d

Please sign in to comment.