fix(archive): lock the sequences a renamed folder carries
A mass rename moved the folders of nested sequences while holding only the lease of the sequence whose folder moved, so an ingest, an editor save or a thumbnail pass of a nested sequence kept writing in the folder as it moved: on Windows the move failed and left the rename pending; elsewhere the writer recreated the old folder and the nested step then failed. A moving step now takes the sequence lease, then the thumbnail lease, of itself and of every sequence it carries, by id, checks them all before anything moves, and records the carried sequences' sidecars and index rows before letting go, so they are journaled together. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
2 files changed
+108
-33
No files matched your search
@@ -136,6 +136,30 @@ public sealed class MassRenameTests(TestContext context)
|
||||
Assert.Empty((await fx.Service.FindOrphansAsync(fx.Archive.Id, fx.Ct)).MissingSequences);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AFolderMovesOnceTheWritersOfTheSequencesInsideAreDone()
|
||||
{
|
||||
await using var fx = await CreateAsync(context);
|
||||
var ids = await NestedAsync(fx);
|
||||
var before = await StateAsync(fx, ids);
|
||||
var plan = await fx.Service.PlanRenameAsync(fx.Archive.Id, [ids[0]], "moved/{date}", null, fx.Ct);
|
||||
|
||||
// An ingest into trips/day2 holds that sequence's lease; a thumbnail pass of trips/day2/dawn holds its pack's.
|
||||
Task apply;
|
||||
using (await LeaseFile.AcquireAsync(fx.Paths.LocksDirectory, $"seq-{ids[1]:N}", "ingest", TimeSpan.FromSeconds(5), cancellationToken: fx.Ct))
|
||||
using (await LeaseFile.AcquireAsync(fx.Paths.LocksDirectory, $"thumbs-{ids[2]:N}", "thumbnails", TimeSpan.FromSeconds(5), cancellationToken: fx.Ct))
|
||||
{
|
||||
apply = fx.Service.ApplyRenameAsync(plan, null, fx.Ct);
|
||||
await Task.Delay(500, fx.Ct);
|
||||
Assert.False(apply.IsCompleted);
|
||||
Assert.True(Directory.Exists(Path.Combine(fx.Paths.Root, "trips", "day2", "dawn")), "nothing moved while they write");
|
||||
}
|
||||
|
||||
await apply;
|
||||
Assert.SequenceEqual(Expected(plan, before), await StateAsync(fx, ids));
|
||||
Assert.Empty(RenameJournal.ListPending(fx.Paths));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task NestedSequencesMovedTogetherLeaveTheirFolderFirst()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user