feat: owner review 2 phase 4b: mass conversion after import (#13)
CI / Build and test (push) Failing after 3m1s
CI / PostgreSQL 16 integration (push) Skipped
CI / PostgreSQL 17 integration (push) Skipped
CI / Docker image (push) Skipped
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 10s
Release / Build, test and publish (push) Successful in 15m31s
Release / Server image (push) Successful in 1m13s

Convert photos already in the archive to JPEG, TIFF-16 or Linear DNG, from the panel's Library and the desktop's Archive and Library. Each run asks Replace (same frames, originals to the trash, recoverable) or New sequence. A dry run lists what converts, what is skipped and why, size before and after, and free space; the job converts exactly the confirmed photos, resumes, and commits all or nothing per sequence. A conversion never changes what Chronos reads from a photo. Replaced originals are erased only on the archive's own word that their conversion is gone. Desktop TIFFs that WIC showed black or as noise now go to the managed reader; the Edit picker no longer spins a core.

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 #13.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-11-03 10:41:50 +01:00
1 parent 7e4a3b481d
commit efa87f68ce
354 files changed
+24530 -843

No files matched your search

@@ -103,6 +103,56 @@ public abstract class JobRepositoryTests(TestContext context) : RepositoryTest(c
return job;
}
[Test]
public async Task HoldsNameTheTargetsOfRunningAndPausedJobsAndOnlyAVerifysParameters()
{
// What a dry run counts as busy, read at every one and at every sequence a conversion comes to: never the parameters
// a conversion or an import keeps, nor the row of the job asking.
var db = await OpenChronosAsync();
Guid a = Guid.CreateVersion7(), b = Guid.CreateVersion7(), archive = Guid.CreateVersion7();
var convert = await EnqueueAsync(db, TestData.Job(JobKind.Convert) with { TargetIds = [a, b], ParametersJson = "{\"fingerprint\": \"f\"}", State = JobState.Running });
var verify = await EnqueueAsync(db, TestData.Job(JobKind.Verify) with { TargetIds = [archive], ParametersJson = "{\"sequenceIds\": []}", State = JobState.Paused });
await EnqueueAsync(db, TestData.Job(JobKind.Thumbs) with { TargetIds = [a] });
await EnqueueAsync(db, TestData.Job(JobKind.Scan) with { TargetIds = [archive], State = JobState.Done, Finished = TestData.Now });
var holds = await db.Jobs.ListHoldsAsync(cancellationToken: Ct);
Assert.SequenceEqual(new[] { convert.Id, verify.Id }.Order(), holds.Select(h => h.Id).Order());
var running = holds.Single(h => h.Id == convert.Id);
Assert.Equal((JobKind.Convert, (string?)null), (running.Kind, running.ParametersJson));
Assert.SequenceEqual([a, b], running.TargetIds);
var paused = holds.Single(h => h.Id == verify.Id);
Assert.Equal((JobKind.Verify, verify.ParametersJson), (paused.Kind, paused.ParametersJson));
Assert.SequenceEqual([verify.Id], (await db.Jobs.ListHoldsAsync(convert.Id, Ct)).Select(h => h.Id));
Assert.Equal(convert.Created, await db.Jobs.GetCreatedAsync(convert.Id, Ct));
Assert.Null(await db.Jobs.GetCreatedAsync(Guid.CreateVersion7(), Ct));
}
[Test]
public async Task BriefListsReadEveryFieldButTheParameters()
{
var db = await OpenChronosAsync();
var job = TestData.Job(JobKind.Convert, JobPriority.User) with
{
TargetIds = [Guid.CreateVersion7(), Guid.CreateVersion7()],
TargetLabel = "Harbour sunset",
ParametersJson = "{\"fingerprint\": \"f\"}",
LogTail = "line 1",
CreatedBy = Guid.CreateVersion7(),
ScheduleId = Guid.CreateVersion7(),
};
await db.Jobs.EnqueueAsync(job, Ct);
var brief = Assert.NotNull((await db.Jobs.ListBriefAsync(JobState.Queued, JobKind.Convert, 10, null, Ct)).Items.SingleOrDefault());
Assert.SequenceEqual(job.TargetIds, brief.TargetIds);
Assert.Equal(job with { TargetIds = brief.TargetIds, ParametersJson = null }, brief);
Assert.Equal(job.ParametersJson, (await db.Jobs.ListAsync(JobState.Queued, JobKind.Convert, 10, null, Ct)).Items.Single().ParametersJson);
Assert.Empty((await db.Jobs.ListBriefAsync(JobState.Running, null, 10, null, Ct)).Items);
var next = Assert.NotNull((await db.Jobs.ListQueuedBriefAsync([JobKind.Convert], 10, Chronos.Data.Jobs.JobPriorityQueue.Off, Ct)).SingleOrDefault());
Assert.Equal((job.Id, (string?)null), (next.Id, next.ParametersJson));
Assert.Empty(await db.Jobs.ListQueuedBriefAsync([], 10, Chronos.Data.Jobs.JobPriorityQueue.Off, Ct));
}
[Test]
public async Task ThePriorityQueueClaimsTheHigherKindsFirst()
{
@@ -1,3 +1,4 @@
using Chronos.Core.Imaging;
using Chronos.Core.Model;
using Chronos.Data.Repositories;
using Chronos.Data.Tests.Infrastructure;
@@ -6,8 +7,9 @@ using Chronos.Testing;
namespace Chronos.Data.Tests.Repositories;
/// <summary>
/// The stamp of what a Reorganize plans from in an archive's index (<see cref="SequenceRepository.GetStampAsync"/>) on both
/// dialects: the server makes a kept Reorganize plan again once it is another one, and only then (owner review 2, R7).
/// The stamps of what a Reorganize and a conversion plan from in an archive's index (<see cref="SequenceRepository.GetStampAsync"/>,
/// <see cref="SequenceRepository.GetConvertStampAsync"/>) on both dialects: the server makes a kept plan again once its
/// stamp is another one, and only then (owner review 2, R7).
/// </summary>
public abstract class SequenceStampTests(TestContext context) : RepositoryTest(context)
{
@@ -77,6 +79,53 @@ public abstract class SequenceStampTests(TestContext context) : RepositoryTest(c
Assert.False(verified == all || verified == uploaded, "a photo hashed");
}
[Test]
public async Task TheConvertStampFollowsThePhotosAConversionPlansFrom()
{
var db = await OpenChronosAsync();
var archive = TestData.Archive();
await db.Archives.UpsertAsync(archive, Ct);
var roof = TestData.Sequence(archive.Id, new DateTime(2026, 9, 28, 18, 0, 0), "Roof");
var ridge = TestData.Sequence(archive.Id, new DateTime(2026, 9, 29, 7, 0, 0), "Ridge");
foreach (var sequence in new[] { roof, ridge }) await db.Sequences.UpsertAsync(sequence, Ct);
var photo = await PhotoAsync(db, roof, 0);
var elsewhere = await PhotoAsync(db, ridge, 0);
IReadOnlyList<Guid> planned = [roof.Id];
var stamp = await db.Sequences.GetConvertStampAsync(archive.Id, planned, Ct);
Assert.Equal(stamp, await db.Sequences.GetConvertStampAsync(archive.Id, planned, Ct));
Assert.Equal(stamp, await db.Sequences.GetConvertStampAsync(archive.Id, [roof.Id, roof.Id], Ct));
Assert.NotEqual(stamp, await db.Sequences.GetConvertStampAsync(archive.Id, null, Ct));
// What a conversion does not read: the photos of a sequence not planned, light statistics, tags, a verify time.
Assert.Equal(1, await db.Frames.UpdateFlagsAsync([elsewhere.Id], FrameFlags.Missing, FrameFlags.None, Ct));
Assert.Equal(1, await db.Frames.UpdateLightStatsAsync([new FrameLightStats(photo.Id, -2.5, 0.01, 0.02)], Ct));
Assert.True(await db.Sequences.SetTagsAsync(roof.Id, ["sky"], Ct));
Assert.True(await db.Sequences.RecordVerifiedAsync(roof.Id, SequenceStatus.Verified, SequenceStatus.None, TestData.Now, Ct));
Assert.Equal(stamp, await db.Sequences.GetConvertStampAsync(archive.Id, planned, Ct));
// What it reads, without another frames version: each flag that keeps a photo as it is (a scan's, a verify's, a
// decode's), the format a decode records, the hash a verify records. Cleared again, the stamp is the one before.
var seen = new HashSet<string>(StringComparer.Ordinal) { stamp };
foreach (var flag in new[] { FrameFlags.Missing, FrameFlags.Corrupt, FrameFlags.PreviewOnly, FrameFlags.Undecodable })
{
Assert.Equal(1, await db.Frames.UpdateFlagsAsync([photo.Id], flag, FrameFlags.None, Ct));
Assert.True(seen.Add(await db.Sequences.GetConvertStampAsync(archive.Id, planned, Ct)), flag.ToString());
Assert.Equal(1, await db.Frames.UpdateFlagsAsync([photo.Id], FrameFlags.None, flag, Ct));
Assert.Equal(stamp, await db.Sequences.GetConvertStampAsync(archive.Id, planned, Ct));
}
Assert.Equal(1, await db.Frames.UpdateTiersAsync([new FrameTierFields(photo.Id, FrameFlags.None, 0, 0, ImageFileFormat.Dng)], Ct));
Assert.True(seen.Add(await db.Sequences.GetConvertStampAsync(archive.Id, planned, Ct)), "format");
var unhashed = await PhotoAsync(db, roof, 1, hashed: false);
Assert.True(seen.Add(await db.Sequences.GetConvertStampAsync(archive.Id, planned, Ct)), "a photo added");
await VerifyAsync(db, unhashed);
Assert.True(seen.Add(await db.Sequences.GetConvertStampAsync(archive.Id, planned, Ct)), "hashed by a verify");
// With every sequence planned, a flag on any photo changes it.
var all = await db.Sequences.GetConvertStampAsync(archive.Id, null, Ct);
Assert.Equal(1, await db.Frames.UpdateFlagsAsync([elsewhere.Id], FrameFlags.None, FrameFlags.Missing, Ct));
Assert.NotEqual(all, await db.Sequences.GetConvertStampAsync(archive.Id, null, Ct));
}
/// <summary>
/// A photo indexed into a sequence, as an upload does, or without its hash, as a scan does: the frame, then the row's
/// counts and frames version.