fix(proxies): use only a frame's own proxy and let tiers, reports and built flags follow it

- Renders, analyses, the server's manifests and proxy downloads take a proxy only
  when its Exif capture time is the frame's (ArchiveImages.IsProxyOf); one left at
  the index by a frame renumbered since counts as missing and is asked for again
  (V-24).
- A frame whose original the host reads through its proxy (HEIF on the server) is
  preview-only only while it has none: the light analysis and the proxy pass keep
  the flag, the preview-only count, the light finding and the advisor's output cap
  in step with the proxies, and an arriving proxy queues a light analysis on the
  server (V-1, V-25).
- The deep checkpoint's content key includes whether each frame is read from its
  original or its proxy, and analysis.json lists the frames measured from proxies;
  an unreadable verdict on a frame now read from its proxy makes the report stale
  (V-26).
- Thumbnails drawn from proxies are compared with the archive's thumbnail size
  instead of 320 px (V-27).
- A resumed thumbnail or proxy pass sets ThumbsBuilt/ProxiesBuilt only when the
  frames an earlier run did still have theirs, and the proxy pass logs frames
  waiting for a client's proxy apart from unreadable ones (V-28).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-12 16:07:31 +00:00
1 parent 32a0e9bbc1
commit b4f1fa32d5
22 files changed
+601 -59

No files matched your search

@@ -62,6 +62,31 @@ public sealed class ProxyUploadTests(TestContext context)
}
}
[Test]
public async Task AnotherPhotosProxyInTheFramesPlaceIsAskedForAgainAndNeverServed()
{
await using var server = await TestServer.StartAsync(context, services: ArchiveModule.Register);
var (editor, _, _) = await server.UserAsync("alberto", "editor");
var upload = await Uploads.UploadAsync(editor, Heif(1), "IMG_0001.HEIC", sessionKey: "roof");
var frame = Assert.NotNull(await server.Database.Frames.GetAsync(upload.FrameId));
var sequence = Assert.NotNull(await server.Database.Sequences.GetAsync(upload.SequenceId));
// Proxies are named by frame index: after a frame was inserted before this one, its place holds another photo's.
var path = new Core.Archiving.ArchivePaths(server.Options.ArchivePath).Sequence(sequence.Folder).Proxy(frame.Index);
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
await File.WriteAllBytesAsync(path, Proxy(frame.CapturedAt!.Value.AddSeconds(-10)));
Assert.Equal((true, false), Wanted((await ManifestAsync(editor, upload.SequenceId)).Frames.Single()));
using (var served = await editor.GetAsync($"/api/v1/frames/{frame.Id}/proxy"))
Assert.Equal("asset_missing", (await served.ExpectErrorAsync(HttpStatusCode.NotFound, "not_found")).Details);
// The frame's own proxy takes its place.
var proxy = Proxy(frame.CapturedAt!.Value);
using (var stored = await PutAsync(editor, frame.Id, proxy))
await stored.ExpectAsync(HttpStatusCode.NoContent);
Assert.Equal((false, true), Wanted((await ManifestAsync(editor, upload.SequenceId)).Frames.Single()));
await Http.BytesEqualAsync(proxy, editor.GetByteArrayAsync($"/api/v1/frames/{frame.Id}/proxy"));
}
[Test]
public async Task FramesTheServerDecodesAskForNoProxy()
{
@@ -87,6 +112,8 @@ public sealed class ProxyUploadTests(TestContext context)
return JpegEncoder.Encode(image, new JpegEncodeOptions { Quality = 85, App1Segments = [exif[4..]] });
}
private static (bool WantsProxy, bool HasProxy) Wanted(ManifestFrame frame) => (frame.WantsProxy, frame.HasProxy);
private static Task<HttpResponseMessage> PutAsync(HttpClient client, Guid frameId, byte[] body)
{
var content = new ByteArrayContent(body);