feat(server): run on the real archive engine
ArchiveModule registers the archive engine as the server's ingest, its proxy/thumbnail locator and its job handlers (through the new IJobHandlerProvider); Program.cs passes it to ServerHost.Build. The server opens its archive through ArchiveService so archive.json always exists. The server's path-safety helper is renamed ArchivePathGuard to stop clashing with the archive layout's ArchivePaths, and the server migration is renumbered 0003. An end-to-end test uploads a photo, finds it in the layout and fetches the thumbnail built by the queued job. CI's PostgreSQL jobs now run the server tests too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
15 files changed
+150
-22
No files matched your search
@@ -29,7 +29,7 @@ public static class FileEndpoints
|
||||
private static async Task<IResult> OriginalAsync(HttpContext context, Guid id, TitanoDatabase db, ServerArchive archive)
|
||||
{
|
||||
if (await db.Frames.GetAsync(id, context.RequestAborted) is not { } frame) return ApiErrors.NotFound(context, "frame");
|
||||
if (ArchivePaths.ExistingFile(archive.Root, frame.RelativePath) is not { } file) return ApiErrors.NotFound(context, "file_missing");
|
||||
if (ArchivePathGuard.ExistingFile(archive.Root, frame.RelativePath) is not { } file) return ApiErrors.NotFound(context, "file_missing");
|
||||
return FileResponses.Serve(context, file, 0, file.Length, FileResponses.ContentTypeOf(frame.FileName), Immutable, frame.Sha256, frame.FileName)
|
||||
?? ApiErrors.NotFound(context, "file_missing");
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public static class FileEndpoints
|
||||
if (await db.Frames.GetAsync(id, ct) is not { } frame || await db.Sequences.GetAsync(frame.SequenceId, ct) is not { } sequence)
|
||||
return ApiErrors.NotFound(context, "frame");
|
||||
var location = await locator.LocateAsync(archive.Current, sequence, frame, kind, ct);
|
||||
if (location is null || !ArchivePaths.IsInside(archive.Root, location.Path)) return ApiErrors.NotFound(context, "asset_missing");
|
||||
if (location is null || !ArchivePathGuard.IsInside(archive.Root, location.Path)) return ApiErrors.NotFound(context, "asset_missing");
|
||||
var file = new FileInfo(location.Path);
|
||||
if (!file.Exists || file.LinkTarget is not null) return ApiErrors.NotFound(context, "asset_missing");
|
||||
var etag = string.Create(CultureInfo.InvariantCulture, $"{kind}-{frame.Id:N}-{file.LastWriteTimeUtc.Ticks}-{location.Offset}");
|
||||
@@ -51,7 +51,7 @@ public static class FileEndpoints
|
||||
private static async Task<IResult> RenderAsync(HttpContext context, Guid id, TitanoDatabase db, ServerArchive archive)
|
||||
{
|
||||
if (await db.Renders.GetAsync(id, context.RequestAborted) is not { } render) return ApiErrors.NotFound(context, "render");
|
||||
if (ArchivePaths.ExistingFile(archive.Root, render.OutputPath) is not { } file) return ApiErrors.NotFound(context, "file_missing");
|
||||
if (ArchivePathGuard.ExistingFile(archive.Root, render.OutputPath) is not { } file) return ApiErrors.NotFound(context, "file_missing");
|
||||
var etag = string.Create(CultureInfo.InvariantCulture, $"r-{render.Id:N}-{file.Length}-{file.LastWriteTimeUtc.Ticks}");
|
||||
return FileResponses.Serve(context, file, 0, file.Length, FileResponses.ContentTypeOf(file.Name), Immutable, etag, file.Name)
|
||||
?? ApiErrors.NotFound(context, "file_missing");
|
||||
|
||||
Reference in new issue
Block a user