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
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:
1 parent
9aa818ed47
commit
7e4a3b481d
416 files changed
+15304
-1572
No files matched your search
@@ -330,6 +330,59 @@ public sealed class EditorSmokeTests
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// A Reorganize of this PC moves the folder of the sequence open in the editor: the editor reads it again where it is
|
||||
/// now as soon as its step is done, so its frames decode and its project goes there.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public Task AnOpenSequenceIsReadAgainWhereAReorganizeMovedIt() => ScreenHost.RunAsync(async () =>
|
||||
{
|
||||
await using var app = await ScreenSmokeTests.SampleApp.StartAsync();
|
||||
var id = await app.Sample.FillEditorAsync();
|
||||
var db = app.Services.Database!;
|
||||
var archives = app.Services.Archives!;
|
||||
var source = new LocalSequenceSource(db, id, Chronos.Core.Imaging.Decoders.DecoderFactory.CreateClient(null), null);
|
||||
var content = await source.LoadAsync(CancellationToken.None);
|
||||
var editor = new EditorViewModel(app.Shell, new EditorSession(source, content, []), [], EncoderHost.Client);
|
||||
await using (editor)
|
||||
{
|
||||
var archive = (await db.Archives.GetAsync(content.Sequence.ArchiveId))!;
|
||||
var templates = new Chronos.Core.Archiving.RenameTemplates("Moved/{date}");
|
||||
var plan = await archives.PlanReorganizeAsync(archive.Id, [id], templates, CancellationToken.None);
|
||||
var moved = plan.Steps.Single().ToFolder;
|
||||
await using var engine = new Chronos.Data.Jobs.JobEngine(db, archives.CreateJobHandlers(), new Chronos.Data.Jobs.JobEngineOptions
|
||||
{
|
||||
WorkerId = "test",
|
||||
Kinds = [JobKind.Move],
|
||||
PollInterval = TimeSpan.FromMilliseconds(50),
|
||||
});
|
||||
await engine.StartAsync(CancellationToken.None);
|
||||
var job = await Chronos.Data.Archiving.ArchiveJobs.EnqueueAsync(engine, Chronos.Data.Archiving.ArchiveJobs.Reorganize(archive, plan, templates));
|
||||
// The editor reads its photos as it opens; on Windows the folder cannot move while one is open, and the job that
|
||||
// failed holds the plan for its retry.
|
||||
for (var attempt = 1; ; attempt++)
|
||||
{
|
||||
Job? ended = null;
|
||||
for (var i = 0; i < 1200 && ended is null; i++)
|
||||
{
|
||||
await Task.Delay(25);
|
||||
if (await db.Jobs.GetAsync(job.Id) is { State: JobState.Done or JobState.Failed or JobState.Cancelled } now) ended = now;
|
||||
}
|
||||
Assert.NotNull(ended, "the move job ends");
|
||||
if (ended!.State == JobState.Done) break;
|
||||
Assert.True(ended.State == JobState.Failed && attempt < 20, ended.Error);
|
||||
await Task.Delay(250);
|
||||
await engine.ResumeAsync(job.Id, CancellationToken.None);
|
||||
}
|
||||
|
||||
for (var i = 0; i < 400 && editor.Session.Content.Sequence.Folder != moved; i++) await Task.Delay(25);
|
||||
Assert.Equal(moved, editor.Session.Content.Sequence.Folder);
|
||||
Assert.True(await source.FramesCurrentAsync(CancellationToken.None), "the editor holds the frames where they are now");
|
||||
using var frame = await source.DecodeAsync(0, 32, Chronos.Core.Imaging.DecodePurpose.Thumbnail, CancellationToken.None);
|
||||
Assert.NotNull(frame, "its frames decode");
|
||||
}
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// At the 1200 px minimum beside the 200 px rail (owner review 1, R1), the preview's tools stay inside the preview in
|
||||
/// every language, crop mask on (the crop-result tool enabled): they take a second line rather than lose Play and Full screen.
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user