Minor CDN-CS work

This commit is contained in:
Rory&
2026-06-19 05:58:49 +02:00
parent 7b9b87f308
commit d401aea643
6 changed files with 6 additions and 6 deletions
@@ -24,13 +24,12 @@ public class UserController(LruFileCache lfc, IFileSource fs, CdnWorkerService c
}
else
entry = await lfc.GetOrAdd(cacheKey, async () => {
var original = await fs.GetFile(Request.Path);
var res = await cws.GetRawClient("q8").GetAsync("/scale" + Request.Path + Request.QueryString);
var outStream = await res.Content.ReadAsStreamAsync();
return new LruFileCache.Entry {
Data = outStream.ReadToEnd().ToArray(),
MimeType = res.Content.Headers.ContentType?.ToString() ?? original.MimeType
MimeType = res.Content.Headers.ContentType?.ToString() ?? (await fs.GetFile(Request.Path)).MimeType
};
});
@@ -8,7 +8,7 @@ namespace Spacebar.Cdn.Extensions;
[ApiController]
public class ImageController(LruFileCache lfc, IFileSource fs, CdnWorkerService cws) : ControllerBase {
public async Task<IActionResult> GetImage(string path) {
protected async Task<IActionResult> GetImage(string path) {
DiscordImageResizeParams resizeParams = Request.GetResizeParams();
var cacheKey = path + resizeParams.ToSerializedName();
if (!Request.Query.Any() || resizeParams.Passthrough) {
@@ -19,7 +19,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Local",
// "LD_LIBRARY_PATH": "/home/Rory/git/spacebar/server-master/extra/admin-api/Spacebar.Cdn/result-lib/lib/",
"STORAGE_PATH": "./files"
"STORAGE_PATH": "/mnt/data/dedicated/spacebar-storage"
}
}
}
@@ -11,9 +11,10 @@ public class DiscordImageResizeParams {
public bool SpacebarAllowUpscale { get; set; } = false;
public bool SpacebarOptimiseGif { get; set; } = true;
public string Format { get; set; } = "webp";
public string ToSerializedName() {
return $"{(Animated ? "a_" : "")}{Size}px_{Quality.ToString()}_u.{SpacebarAllowUpscale}_o.{SpacebarOptimiseGif}";
return $"{(Animated ? "a_" : "")}{Size}px_{Quality.ToString()}_u.{SpacebarAllowUpscale}_o.{SpacebarOptimiseGif}.{Format}";
}
}
@@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ArcaneLibs" Version="1.0.1-preview.20260420-212318"/>
<PackageReference Include="ArcaneLibs" Version="1.0.1-preview.20260619-035441"/>
<!-- i dont think native performance here is worth it? -->
<PackageReference Include="Magick.NET-Q16-HDRI-AnyCPU" Version="14.13.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.8" />