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
@@ -171,7 +171,27 @@ public sealed class ReorganizeTests(TestContext context)
|
||||
var plan = Make(manifest);
|
||||
Assert.Equal(64, plan.Fingerprint().Length);
|
||||
Assert.Equal(plan.Fingerprint(), Make(manifest).Fingerprint());
|
||||
Assert.NotEqual(plan.Fingerprint(), Make(manifest with { Versions = new ManifestVersions { Frames = 5 } }).Fingerprint());
|
||||
// A photo received since under the name the plan gives it raises the frames version only: the plan is the one shown.
|
||||
var received = manifest with
|
||||
{
|
||||
Versions = new ManifestVersions { Frames = 5 },
|
||||
Frames = [.. manifest.Frames, manifest.Frames[0] with { Id = Guid.NewGuid(), I = 1, File = "originals/002.JPG", CapturedAt = Start.AddSeconds(10) }],
|
||||
};
|
||||
Assert.Equal(plan.Fingerprint(), Make(received).Fingerprint());
|
||||
// One the plan would rename too, or a file renamed otherwise, is another plan.
|
||||
Assert.NotEqual(plan.Fingerprint(), Make(received with { Frames = [.. received.Frames.SkipLast(1), received.Frames[1] with { File = "originals/b.JPG" }] }).Fingerprint());
|
||||
Assert.NotEqual(plan.Fingerprint(), Make(manifest with { Frames = [manifest.Frames[0] with { File = "originals/c.JPG" }] }).Fingerprint());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AStepNamedAfterTheTitleSaysSo()
|
||||
{
|
||||
var manifest = Sequence("originals/a.JPG");
|
||||
RenameStep Step(string? folder, string? file) => RenamePlanner.Plan(Guid.NewGuid(), [new RenameSubject(manifest.Id, "s", "Roof", Start, null, null, null)
|
||||
{ Files = new SequenceFiles(manifest, [.. manifest.Frames.Select(f => f.File)]) }], folder, null, ["s"], _ => false, fileTemplate: file).Steps.Single();
|
||||
Assert.True(Step("moved/{TITLE}", null) is { MovesFolder: true, NamedByTitle: true, UsesTitle: true, Retitles: false });
|
||||
Assert.True(Step(null, "{title}_{n:000}") is { FileChanges: 1, NamedByTitle: true, UsesTitle: true });
|
||||
Assert.True(Step("moved/{date}", "{n:000}") is { MovesFolder: true, FileChanges: 1, NamedByTitle: false, UsesTitle: false });
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -560,4 +580,34 @@ public sealed class ReorganizeTests(TestContext context)
|
||||
Assert.FileMissing(sequence.File("originals/0001.CR2"));
|
||||
Assert.Empty(Directory.EnumerateFiles(sequence.Originals, ".chronos-rename-*"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void APhotoThatTookItsNewNameGoesBackWithACompanionWhoseNewNameIsTaken()
|
||||
{
|
||||
var sequence = Folder(out _);
|
||||
var manifest = Sequence("originals/A.CR2");
|
||||
Write(sequence, "originals/A.CR2", "photo");
|
||||
Write(sequence, "originals/A.xmp", "sidecar");
|
||||
var id = manifest.Frames[0].Id;
|
||||
FileRename[] moves = [new(id, "originals/A.CR2", "originals/0001.CR2"), new(id, "originals/A.xmp", "originals/0001.xmp", Companion: true)];
|
||||
var journal = FileRenameJournal.Create(manifest.Versions.Frames, moves, "t6") with { Phase = 2 };
|
||||
FileRenameJournal.Write(sequence, journal);
|
||||
foreach (var f in journal.Files) File.Move(sequence.File(f.From), sequence.File(f.Temp));
|
||||
// Stopped once the photo took its new name, before its companion did; then something took the companion's, and the
|
||||
// photo's old name too.
|
||||
File.Move(sequence.File(journal.Files[0].Temp), sequence.File(journal.Files[0].To));
|
||||
Write(sequence, "originals/0001.xmp", "other");
|
||||
Write(sequence, "originals/A.CR2", "another");
|
||||
|
||||
// The photo goes back with its companion, both to the first free number of its old name; the frame names the photo.
|
||||
var recovered = Assert.NotNull(FileRenameJournal.Recover(sequence, manifest));
|
||||
Assert.Equal("originals/A_2.CR2", recovered.Frames.Single().File);
|
||||
Assert.Equal(("photo", "sidecar"), (Read(sequence, "originals/A_2.CR2"), Read(sequence, "originals/A_2.xmp")));
|
||||
Assert.Equal(("other", "another"), (Read(sequence, "originals/0001.xmp"), Read(sequence, "originals/A.CR2")));
|
||||
Assert.FileMissing(sequence.File("originals/0001.CR2"));
|
||||
Assert.Empty(Directory.EnumerateFiles(sequence.Originals, ".chronos-rename-*"));
|
||||
// Run again, every file stays where it is.
|
||||
Assert.Equal("originals/A_2.CR2", Assert.NotNull(FileRenameJournal.Recover(sequence, manifest)).Frames.Single().File);
|
||||
Assert.Equal(("photo", "sidecar"), (Read(sequence, "originals/A_2.CR2"), Read(sequence, "originals/A_2.xmp")));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user