fix: conversions on the released phase 4a keep out of folders a sequence left

Phase 4b and its first fix round were written on phase 4a before its rounds 4-6. Moved onto the
released 4a, the conversion now follows 4a's rule for writers into a sequence's folder
(SequenceFolders.Holds), and the parallel fixes meet:

- The job leaves a sequence another index moved away (its folder missing, or holding another
  sequence's sidecar) as Blocked with Errors.Archive.FolderMoved, nothing settled, staged or
  replaced there; the retry after this index's scan converts it where it is. It read the
  sidecar there and reported the reader's technical text.
- New sequence reads the source's project under the source's lease, where its sidecar was just
  read as its own, and writes the new sequence's project under that sequence's lease only into
  a folder that holds it. It read the project from the folder the row named afterwards, without
  a lease, and wrote through the store without the check.
- Download originals (resolved in the cherry-pick of the trash and sync fix, tested here) swaps
  a copy fetched in another encoding into its missing frame after the transfers, as round 6
  restores originals, and only once the sequence is found in the folder the index has;
  otherwise the copies stay staged and the job fails with FolderMoved after its other work.
  The swap ran inside the transfer loop and failed the job at the first refusal.
- The New sequence wording of the three skip reasons the codecs fix added (Archive.Convert.
  NotCopied.EightBit, ColorProfile, TooLarge, en and it): the server and the desktop look them
  up by reason.
- The server's free space test sets the staging folder's figures too: the job fix measures the
  tighter of the archive root's and the staging folder's volumes.

Tests: a conversion of a sequence another index moved (its folder taken or empty), and a
download whose missing frame takes the server's conversion where the sequence is now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-10-27 22:33:11 +01:00
1 parent 8174852a2c
commit e3cbe30b29
6 files changed
+144 -28

No files matched your search

+11 -4
View File
@@ -2,6 +2,7 @@ using System.Globalization;
using System.Net;
using System.Net.Http.Json;
using Microsoft.Extensions.DependencyInjection;
using Chronos.Core.Archiving;
using Chronos.Core.Codecs.Jpeg;
using Chronos.Core.Imaging;
using Chronos.Core.Localization;
@@ -273,22 +274,28 @@ public sealed class ConvertTests(TestContext context)
await UntilIdleAsync(server);
var request = new ConvertRequest([id], false, "linear-dng", null, "replace", DryRun: true);
const long Full = 1_000_000, Free = 100_000_000_000;
// A conversion counts the tighter of the archive root's volume and its staging folder's: one volume here.
void Set(long free)
{
foreach (var folder in (string[])[server.Options.ArchivePath, new ArchivePaths(server.Options.ArchivePath).StagingDirectory])
volumes.Set(folder, new VolumeFigures(free, 4 * Free));
}
volumes.Set(server.Options.ArchivePath, new VolumeFigures(Full, 4 * Free));
Set(Full);
var tight = await DryRunAsync(admin, request);
Assert.Equal((false, (long?)Full), (tight.Space.Enough, tight.Space.Free));
using (var refused = await admin.PostAsJsonAsync(Url, request with { DryRun = false, Fingerprint = tight.Fingerprint }, ProtocolJson.Default.ConvertRequest))
Assert.Equal(tight.Space.Required.ToString(CultureInfo.InvariantCulture), (await refused.ExpectErrorAsync(HttpStatusCode.Conflict, "not_enough_space")).Details);
// Space freed since: the plan kept, with the free space now; and the confirmation measures it again too.
volumes.Set(server.Options.ArchivePath, new VolumeFigures(Free, 4 * Free));
Set(Free);
var freed = await DryRunAsync(admin, request);
Assert.Equal((true, (long?)Free, tight.Fingerprint, tight.Space.Required), (freed.Space.Enough, freed.Space.Free, freed.Fingerprint, freed.Space.Required));
Assert.Equal(1, server.Services.GetRequiredService<PlanCache>().Count);
volumes.Set(server.Options.ArchivePath, new VolumeFigures(Full, 4 * Free));
Set(Full);
using (var filled = await admin.PostAsJsonAsync(Url, request with { DryRun = false, Fingerprint = freed.Fingerprint }, ProtocolJson.Default.ConvertRequest))
await filled.ExpectErrorAsync(HttpStatusCode.Conflict, "not_enough_space");
volumes.Set(server.Options.ArchivePath, new VolumeFigures(Free, 4 * Free));
Set(Free);
using (var applied = await admin.PostAsJsonAsync(Url, request with { DryRun = false, Fingerprint = freed.Fingerprint }, ProtocolJson.Default.ConvertRequest))
await UntilJobAsync(admin, (await applied.ReadAsync(ProtocolJson.Default.JobDto)).Id, "done");
Assert.True((await server.Database.Frames.ListBySequenceAsync(id)).All(f => f.Format == ImageFileFormat.Dng), "converted");