fix(server): keep convert dry runs like Reorganize's, say what a new sequence lacks
The convert endpoint planned the whole selection inside the HTTP request, again for every mode, quality keystroke and confirmation, with no limit: behind a proxy an all-sequence conversion could never get past its dry run or its apply. - ReorganizePlanCache becomes PlanCache, shared by Reorganize and Convert: one plan per key made apart from the request, two at once across both kinds, eight kept, 15-minute timeout, 5-minute lifetime, 503 plan_dropped. Keys are typed records (ReorganizePlanKey, ConvertPlanKey) that also say which exceptions are refusals. - A conversion plan is keyed by archive, a convert stamp of the index (SequenceRepository.GetConvertStampAsync: the Reorganize stamp plus, per planned sequence, the photos' count, sizes, formats, pixel sizes and missing, corrupt, preview-only and undecodable flags), the sequences and the target with the quality that counts. Not the mode: the request's mode and options are set on the kept plan, and the free space is measured again at every request through the engine. A plan made while the volume was away is not kept (503 archive_offline). - New sequence holds the converted copies alone: the dry run says the skipped photos are not copied into it (Archive.Convert.NotCopied.*, Server.Convert.OnPcNew), the panel's totals, column and confirmation give the count, and so does the desktop's summary. - Panel: the preview is asked in Replace's neutral words; a dry run cut off by a proxy is asked again while the totals show how long it takes, plan_dropped is retried once; an apply the server let go plans again, a changed one shows Admin.Convert.PlanChanged, and one with no answer is not resent (its job may be queued). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit f0b1e379ce7c08b6d3459ab25ca6214c8f366f6c)
This commit is contained in:
1 parent
d0bbd77c92
commit
8174852a2c
22 files changed
+927
-342
No files matched your search
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user