feat: owner review 2 phase 4a: Reorganize sequences after import (#12)
CI / Build and test (push) Successful in 9m15s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 15m35s
CI / PostgreSQL 16 integration (push) Successful in 7m26s
CI / PostgreSQL 17 integration (push) Successful in 6m47s
CI / Docker image (push) Successful in 59s
Release / Server image (push) Successful in 1m24s

- Reorganize… on the web panel and the desktop: folder, file and title templates applied to existing sequences, with a dry run and an explicit Apply that runs as a job.
- One naming rule (FrameNaming) for import, upload and Reorganize.
- Crash-safe plan and file journals, held plans, stale-plan refusal; exports move with their folder.
- Writers refuse a folder another program moved or gave to another sequence.
- Server: POST /api/v1/archive/reorganize with a bounded plan cache; template rules.
- Phase 3 docs and translations merged; strings in all 38 languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #12.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-27 21:58:39 +01:00
1 parent 9aa818ed47
commit 7e4a3b481d
416 files changed
+15304 -1572

No files matched your search

@@ -215,6 +215,44 @@ public sealed class ProjectStoreTests(TestContext context)
}
}
[Test]
public async Task AnEditorOpenWhileAReorganizeMovesItsFolderSavesWhereTheSequenceIsNow()
{
var (db, sequenceId, root) = await ArchiveAsync(6);
await using (db)
{
var options = new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(20) };
await using var source = new LocalSequenceSource(db, sequenceId, DecoderFactory.CreateClient(null), null, options);
var content = await source.LoadAsync(context.Cancellation);
var session = new EditorSession(source, content, [], TimeSpan.FromMilliseconds(20));
await using (session)
{
Assert.True(session.SetHero(2));
Assert.True(await session.FlushAsync());
// Only the folder template changed: the Reorganize moves the folder and keeps the frames version.
var service = new ArchiveService(db, options);
var plan = await service.PlanRenameAsync(content.Sequence.ArchiveId, [sequenceId], "Moved/{title}", null, context.Cancellation);
await service.ApplyRenameAsync(plan, null, context.Cancellation);
var moved = new ArchivePaths(root).Sequence(plan.Steps.Single().ToFolder);
Assert.Equal(content.Sequence.FramesVersion, (await db.Sequences.GetAsync(sequenceId))!.FramesVersion);
Assert.False(await source.FramesCurrentAsync(context.Cancellation), "the files are no longer where the editor read them");
session.Edit(p => p with { Exposure = p.Exposure with { ExposureOffsetEv = 0.4 } });
Assert.True(await session.FlushAsync());
var row = (await db.Sequences.GetAsync(sequenceId))!;
Assert.Equal(0.4, ProjectSettings.FromJson(row.SettingsJson!).Exposure.ExposureOffsetEv);
Assert.Equal(row.SettingsJson, File.ReadAllText(moved.ProjectPath), "the moved folder's project has the edit");
Assert.False(Directory.Exists(Path.Combine(root, "Synthetic")), "the folder it left is not created again");
Assert.True(await source.FramesCurrentAsync(context.Cancellation));
Assert.Equal(moved.Exports, session.Content.ExportsFolder);
using var frame = await source.DecodeAsync(1, 32, DecodePurpose.Thumbnail, context.Cancellation);
Assert.NotNull(frame, "the frames are read where they are now");
}
}
}
[Test]
public async Task ASaveThatDoesNotReachTheIndexThrows()
{
@@ -230,6 +268,54 @@ public sealed class ProjectStoreTests(TestContext context)
}
}
[Test]
public async Task ASaveAfterAnotherIndexMovedTheFolderWritesNothing()
{
var (db, sequenceId, root) = await ArchiveAsync(4);
await using (db)
{
await using var source = new LocalSequenceSource(db, sequenceId, DecoderFactory.CreateClient(null), null,
new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(20) });
var content = await source.LoadAsync(context.Cancellation);
// A server sharing the archive moved the folder; this index finds it there at its next scan.
var left = Path.Combine(root, "Synthetic");
Directory.Move(left, Path.Combine(root, "Moved"));
var gone = await Assert.ThrowsAsync<EditorException>(() => source.SaveProjectAsync(content.Project with { HeroFrame = 1 }, content.Project, context.Cancellation));
Assert.Equal(Loc.L("Editor.Error.Missing"), gone.Message);
Assert.False(Directory.Exists(left), "the folder it left is not created again");
Assert.Equal(content.Sequence.SettingsVersion, (await db.Sequences.GetAsync(sequenceId))!.SettingsVersion, "nothing recorded");
}
}
[Test]
public async Task ASaveNeverWritesIntoAnotherSequenceMovedIntoTheFolder()
{
var (db, sequenceId, root) = await ArchiveAsync(4);
await using (db)
{
await using var source = new LocalSequenceSource(db, sequenceId, DecoderFactory.CreateClient(null), null,
new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(20) });
var content = await source.LoadAsync(context.Cancellation);
// A server sharing the archive moved the folder away, then another sequence into the folder it left; this index
// finds both at its next scan.
var paths = new ArchivePaths(root);
Directory.Move(paths.Sequence("Synthetic").Folder, paths.Sequence("Moved").Folder);
var stranger = paths.Sequence("Synthetic");
Directory.CreateDirectory(stranger.MetaDirectory);
ManifestStore.WriteSequence(stranger.ManifestPath, ManifestStore.ReadSequence(paths.Sequence("Moved").ManifestPath) with { Id = Guid.NewGuid() });
const string theirs = """{"exposure":{"deflickerWindow":{"isAuto":false,"manual":7}}}""";
await File.WriteAllTextAsync(stranger.ProjectPath, theirs, context.Cancellation);
var gone = await Assert.ThrowsAsync<EditorException>(() => source.SaveProjectAsync(content.Project with { HeroFrame = 1 }, content.Project, context.Cancellation));
Assert.Equal(Loc.L("Editor.Error.Missing"), gone.Message);
Assert.Equal(theirs, await File.ReadAllTextAsync(stranger.ProjectPath, context.Cancellation), "the other sequence's project is untouched");
Assert.Equal(content.Sequence.SettingsVersion, (await db.Sequences.GetAsync(sequenceId))!.SettingsVersion, "nothing recorded");
}
}
[Test]
public async Task JobsGoToTheEngine()
{