fix(reorganize): a rename journal that cannot be read no longer stops the archive from opening
An archive open lists the pending rename plans; one journal that was not valid JSON threw out of ArchiveService.OpenAsync, so the archive (and the server, at boot) did not open until the file was removed by hand. It is now logged and left in place; its own job fails with the reason instead of planning again over a half-applied plan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
074d09839a
commit
0c2bdedfdf
5 files changed
+59
-8
No files matched your search
@@ -751,4 +751,24 @@ public sealed class ReorganizeTests(TestContext context)
|
||||
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")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ADamagedPlanJournalIsSkippedAtOpenAndFailsItsOwnJob()
|
||||
{
|
||||
var archive = new ArchivePaths(context.CreateTempDirectory("archive"));
|
||||
var good = new RenameJournal(new RenamePlan(Guid.NewGuid(), Guid.NewGuid(), []), []);
|
||||
RenameJournal.Write(archive, good);
|
||||
var damaged = Guid.NewGuid();
|
||||
File.WriteAllText(RenameJournal.PathFor(archive, damaged), "{ \"plan\": ");
|
||||
var empty = Guid.NewGuid();
|
||||
File.WriteAllText(RenameJournal.PathFor(archive, empty), "{}");
|
||||
|
||||
// The archive still opens: the readable journal resumes, the others stay where they are.
|
||||
Assert.Equal(good.Plan.Id, RenameJournal.ListPending(archive).Single().Plan.Id);
|
||||
Assert.True(File.Exists(RenameJournal.PathFor(archive, damaged)));
|
||||
// The job of a damaged plan fails with the reason instead of planning again.
|
||||
Assert.Throws<InvalidDataException>(() => RenameJournal.Read(archive, damaged));
|
||||
Assert.Throws<InvalidDataException>(() => RenameJournal.Read(archive, empty));
|
||||
Assert.Null(RenameJournal.Read(archive, Guid.NewGuid()));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user