fix(reorganize): a sequence still receiving photos keeps its file names and the job goes on
A Reorganize with a file template failed its job at the step of a sequence
a camera was still uploading into, and its retry gave the rest up. Photos
changed since the plan now never refuse a step: that sequence keeps its file
names (FilesKept), its folder and title change as planned, the other steps go
on and the job ends with ReorganizeKept. The fingerprint, the job's
confirmation and the check under the leases pin file renames by their digest
instead of the frames version, so photos filed under the names the plan gives
them no longer make a dry run or a queued job stale.
- A step whose folder or files a template names after {title} checks the
title as a retitle does (RenameStep.NamedByTitle): no name comes from a
title edited since the plan.
- Recovery sends a photo that already took its new name back together with a
companion whose new name was taken, so the two never end up apart.
- ArchiveService.OpenAsync logs a NewerFormatException from resuming a plan
and keeps its journal, so a server still boots.
- Once a step's folder moved, every index row of the step follows it even
when a sidecar cannot be read or written; the step then fails for a retry.
- Job log lines and errors give the real reason for files kept busy (in use
or a new name taken) and for a sidecar of a newer format (new Newer
outcome; strings en and it).
- A plan an archive open completes tells sequenceChanged; the docs that
promised more than that are corrected.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f8554b8af0828ab9b0ff128e694abacdd53e6fd7)
This commit is contained in:
1 parent
59ee982e4d
commit
9e1f109b58
16 files changed
+560
-195
No files matched your search
@@ -284,6 +284,35 @@ public sealed class ReorganizeTests(TestContext context)
|
||||
Assert.SequenceEqual(["001.JPG", "002.JPG", "003.JPG"], (await server.Database.Frames.ListBySequenceAsync(id)).Select(f => f.FileName));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AnUploadFiledUnderTheNameThePlanGivesLeavesThePlanToConfirm()
|
||||
{
|
||||
await using var server = await TestServer.StartAsync(context, services: ArchiveModule.Register);
|
||||
var (editor, _, _) = await server.UserAsync("alberto", "editor");
|
||||
var admin = await server.AdminAsync();
|
||||
Guid id = default;
|
||||
for (var i = 0; i < 2; i++) id = (await Uploads.UploadAsync(editor, Photo(i), $"IMG_{i + 1:0000}.JPG", sessionKey: "roof")).SequenceId;
|
||||
await UntilIdleAsync(server);
|
||||
// The archive files new photos as the Reorganize names them; the two filed before do not follow it yet.
|
||||
using (var read = await admin.GetAsync("/api/v1/archive/settings"))
|
||||
{
|
||||
var settings = await read.ReadAsync(ProtocolJson.Default.ArchiveSettingsDto);
|
||||
using var put = await admin.PutAsJsonAsync("/api/v1/archive/settings", settings with { FileTemplate = "{n:000}" }, ProtocolJson.Default.ArchiveSettingsDto);
|
||||
await put.ExpectAsync(HttpStatusCode.OK);
|
||||
}
|
||||
var request = new ReorganizeRequest([id], false, null, "{n:000}", null, DryRun: true);
|
||||
var shown = await DryRunAsync(admin, request);
|
||||
Assert.Equal(2, shown.Files);
|
||||
|
||||
// The camera still uploads before Apply, a photo after the others: it takes the name the plan leaves it, so the plan
|
||||
// confirmed is the one now.
|
||||
await Uploads.UploadAsync(editor, Photo(2), "IMG_0003.JPG", sessionKey: "roof", capturedAt: new DateTime(2026, 9, 28, 18, 3, 0));
|
||||
await UntilIdleAsync(server);
|
||||
Assert.Equal("003.JPG", (await server.Database.Frames.ListBySequenceAsync(id))[^1].FileName);
|
||||
await UntilJobAsync(admin, await ConfirmAsync(admin, request with { DryRun = false, Fingerprint = shown.Fingerprint }), "done");
|
||||
Assert.SequenceEqual(["001.JPG", "002.JPG", "003.JPG"], (await server.Database.Frames.ListBySequenceAsync(id)).Select(f => f.FileName));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AMoveJobPausedBetweenTwoSequencesCompletesTheRestWhenResumed()
|
||||
{
|
||||
|
||||
@@ -19,11 +19,13 @@ internal static class Uploads
|
||||
|
||||
public static string Sha(byte[] data) => Convert.ToHexStringLower(SHA256.HashData(data));
|
||||
|
||||
/// <param name="capturedAt">The capture time the client sends; null: 2026-09-28 18:02:11.</param>
|
||||
public static async Task<StartUploadResponse> StartAsync(HttpClient client, byte[] data, string fileName = "IMG_0001.CR3", Guid? sequenceId = null,
|
||||
string? sessionKey = null, HttpStatusCode expected = HttpStatusCode.Created)
|
||||
string? sessionKey = null, HttpStatusCode expected = HttpStatusCode.Created, DateTime? capturedAt = null)
|
||||
{
|
||||
using var response = await client.PostAsJsonAsync("/api/v1/uploads",
|
||||
new StartUploadRequest(sequenceId, fileName, data.Length, Sha(data), new DateTime(2026, 9, 28, 18, 2, 11), sessionKey), ProtocolJson.Default.StartUploadRequest);
|
||||
new StartUploadRequest(sequenceId, fileName, data.Length, Sha(data), capturedAt ?? new DateTime(2026, 9, 28, 18, 2, 11), sessionKey),
|
||||
ProtocolJson.Default.StartUploadRequest);
|
||||
await response.ExpectAsync(expected);
|
||||
return await response.ReadAsync(ProtocolJson.Default.StartUploadResponse);
|
||||
}
|
||||
@@ -40,9 +42,9 @@ internal static class Uploads
|
||||
|
||||
/// <summary>Start, every chunk, complete; returns the committed frame.</summary>
|
||||
public static async Task<CompleteUploadResponse> UploadAsync(HttpClient client, byte[] data, string fileName = "IMG_0001.CR3", Guid? sequenceId = null,
|
||||
string? sessionKey = null)
|
||||
string? sessionKey = null, DateTime? capturedAt = null)
|
||||
{
|
||||
var start = await StartAsync(client, data, fileName, sequenceId, sessionKey);
|
||||
var start = await StartAsync(client, data, fileName, sequenceId, sessionKey, capturedAt: capturedAt);
|
||||
var id = Assert.NotNull(start.UploadId);
|
||||
var chunks = (data.Length + start.ChunkSize - 1) / start.ChunkSize;
|
||||
for (var i = 0; i < chunks; i++)
|
||||
|
||||
Reference in new issue
Block a user