Skip to content

Commit

Permalink
fix cache
Browse files Browse the repository at this point in the history
  • Loading branch information
0xF6 committed Aug 31, 2024
1 parent 370aa8f commit 12328f6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/controllers/PackageContentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,18 @@ public async Task<IActionResult> DownloadVeinSpecAsync(string id, string version

[HttpGet("@/packages/{id}/{version}/readme")]
public async Task<IActionResult> DownloadReadmeAsync(string id, string version, CancellationToken cancellationToken)
{
if (cache.TryGetValue($"@/packages/{id}/{version}/readme", out string md))
return Content(markdownService.GetHtmlFromMarkdown(md).Content, "text/html");
{
if (version is not ("latest" or "next") && cache.TryGetValue($"@/packages/{id}/{version}/readme", out string md))
return Content(markdownService.GetHtmlFromMarkdown(md).Content, "text/html");

var ver = version switch
{
"latest" or null => new (0, 0, 0, 0, "", "latest"),
"next" => new (0, 0, 0, 0, "", "next"),
not null => NuGetVersion.Parse(version)
};
};



var readmeStream = await content.GetPackageReadmeStreamOrNullAsync(id, ver, cancellationToken);

Expand Down

0 comments on commit 12328f6

Please sign in to comment.