Skip to content

Commit

Permalink
[modgen] Mise en cache de "null" si pas internet lors du check de la …
Browse files Browse the repository at this point in the history
…dernière version de modgen
  • Loading branch information
JabX committed Sep 16, 2024
1 parent 4116b9d commit dc00ef6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
14 changes: 7 additions & 7 deletions TopModel.Generator.Jpa/SpringServerApiGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ private static string GetClassName(string fileName)
return $"{fileName.ToPascalCase()}Controller";
}

private void AddImports(IEnumerable<Endpoint> endpoints, JavaWriter fw, string tag)
{
fw.AddImports(endpoints.Select(e => $"org.springframework.web.bind.annotation.{e.Method.ToPascalCase(true)}Mapping"));
fw.AddImports(GetTypeImports(endpoints, tag));
fw.AddImports(endpoints.SelectMany(e => Config.GetDecoratorImports(e, tag)));
}

private IEnumerable<string> GetTypeImports(IEnumerable<Endpoint> endpoints, string tag)
{
var properties = endpoints.SelectMany(endpoint => endpoint.Params)
Expand Down Expand Up @@ -177,11 +184,4 @@ private void WriteEndpoint(JavaWriter fw, Endpoint endpoint, string tag)

fw.WriteLine(1, $"{returnType} {endpoint.NameCamel}({string.Join(", ", methodParams)});");
}

private void AddImports(IEnumerable<Endpoint> endpoints, JavaWriter fw, string tag)
{
fw.AddImports(endpoints.Select(e => $"org.springframework.web.bind.annotation.{e.Method.ToPascalCase(true)}Mapping"));
fw.AddImports(GetTypeImports(endpoints, tag));
fw.AddImports(endpoints.SelectMany(e => Config.GetDecoratorImports(e, tag)));
}
}
2 changes: 1 addition & 1 deletion TopModel.Utils/ModuleLatestVersion.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace TopModel.Utils;

public record ModuleLatestVersion(string Version, DateTime CheckDate);
public record ModuleLatestVersion(string? Version, DateTime CheckDate);
7 changes: 7 additions & 0 deletions TopModel.Utils/NugetUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public static async Task<PackageArchiveReader> DownloadPackageAsync(string id, s
}
else
{
if (cachedVersion.Version == null)
{
return null;
}

return new TopModelLockModule { Version = cachedVersion.Version };
}
}
Expand All @@ -85,6 +90,8 @@ public static async Task<PackageArchiveReader> DownloadPackageAsync(string id, s
{
// Si on a pas internet par exemple.
cantCheckVersion = true;
Versions[id] = new(null, DateTime.UtcNow);
await WriteAsync();
return null;
}
}
Expand Down

0 comments on commit dc00ef6

Please sign in to comment.