E5: il posto per il prossimo file è quello del file che la copia scrive

La sonda di «Riprova» e del giro misurava il file della libreria, mentre
la copia controlla il file che scrive: una foto che diventa un PNG più
grande toglieva la pausa, la copia si fermava di nuovo e ogni ora c'era
un evento «in pausa» in più; un PNG che diventa un JPG più piccolo non
ripartiva mai; per un fotogramma serviva il posto di tutto il video.

Ora la copia ricorda in memoria quanto ha chiesto al disco quando si è
fermata (ExportCopier.SpaceNeeded) e la sonda usa quella misura per il
primo elemento in attesa di ogni lavoro in pausa
(ListNextPendingFilesAsync); senza misura, dopo un riavvio, il file
della libreria e per un fotogramma il solo margine.

Il giro di una cartella automatica guarda solo i lavori automatici che
riprenderebbe, come dice la specifica (§4.10): senza lavori automatici
in pausa basta che la cartella risponda, e una copia grande di Alberto
in pausa non blocca più i file nuovi che ci stanno (risposta 48). In una
cartella non automatica il giro non riprende nulla e misura come
«Riprova».

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-04 21:16:35 +01:00
1 parent 248b82b590
commit c3d9e02e22
9 files changed
+266 -68

No files matched your search

@@ -434,9 +434,12 @@ public sealed class ExportStoreAutomaticTests
Assert.HasCount(2, events);
}
/// <summary>D11: the first file still to copy of the oldest paused job of a destination.</summary>
/// <summary>
/// D11: the next file still to copy of each paused copy job of a destination, oldest first, with its form; only the
/// automatic jobs when asked.
/// </summary>
[TestMethod]
public async Task FirstPendingBytesOfAPausedRun()
public async Task NextPendingFilesOfThePausedRuns()
{
var ct = TestContext.CancellationToken;
await using var bed = await ExportTestBed.CreateAsync();
@@ -445,15 +448,30 @@ public sealed class ExportStoreAutomaticTests
var a = await FileAsync(bed, bed.Luca, "a", 1, bytes: 111, ct: ct);
var b = await FileAsync(bed, bed.Luca, "b", 2, bytes: 222, ct: ct);
var c = await FileAsync(bed, bed.Luca, "c", 3, bytes: 333, ct: ct);
Assert.IsNull(await bed.Db.Exports.GetFirstPendingBytesAsync(general, ct));
var d = await FileAsync(bed, bed.Luca, "d", 4, video: true, bytes: 444, ct: ct);
Assert.IsEmpty(await bed.Db.Exports.ListNextPendingFilesAsync(general, automaticOnly: false, ct));
var running = await RunAsync(bed, general, ExportRunState.Interrupted, ct, (c.Media, ExportItemState.Pending));
Assert.IsNull(await bed.Db.Exports.GetFirstPendingBytesAsync(general, ct), "solo un lavoro in pausa");
await RunAsync(bed, general, ExportRunState.Paused, ct, (a.Media, ExportItemState.Copied), (b.Media, ExportItemState.Pending), (c.Media, ExportItemState.Pending));
await RunAsync(bed, general, ExportRunState.Paused, ct, (a.Media, ExportItemState.Pending));
Assert.AreEqual(222L, await bed.Db.Exports.GetFirstPendingBytesAsync(general, ct));
Assert.IsNull(await bed.Db.Exports.GetFirstPendingBytesAsync(own, ct));
Assert.IsNotNull(running);
await RunAsync(bed, general, ExportRunState.Interrupted, ct, (c.Media, ExportItemState.Pending));
Assert.IsEmpty(await bed.Db.Exports.ListNextPendingFilesAsync(general, automaticOnly: false, ct), "solo un lavoro in pausa");
var manual = await RunAsync(bed, general, ExportRunState.Paused, ct, (a.Media, ExportItemState.Copied), (b.Media, ExportItemState.Pending), (c.Media, ExportItemState.Pending));
var automatic = await bed.Db.Exports.CreateRunAsync(
new ExportRun { DestinationId = general, Origin = ExportRunOrigin.Automatic, State = ExportRunState.Paused, StartedAt = Make.T0 }, ct);
await bed.Db.Exports.AddItemsAsync(
[new ExportItem { RunId = automatic.Id, MediaId = d.Media, AccountId = bed.Luca.Id, Variant = ExportVariant.Frame, Format = ExportFormat.Png, FrameAt = TimeSpan.Zero }],
ct);
var all = await bed.Db.Exports.ListNextPendingFilesAsync(general, automaticOnly: false, ct);
var items = await bed.Db.Exports.ListItemsAsync(new ExportItemQuery { RunId = manual.Id }, ct);
var frame = (await bed.Db.Exports.ListItemsAsync(new ExportItemQuery { RunId = automatic.Id }, ct)).Single();
CollectionAssert.AreEqual(
new[]
{
new ExportPendingFile(manual.Id, items.Single(i => i.MediaId == b.Media).Id, ExportVariant.Whole, 222),
new ExportPendingFile(automatic.Id, frame.Id, ExportVariant.Frame, 444),
},
all.ToArray());
CollectionAssert.AreEqual(new[] { all[1] }, (await bed.Db.Exports.ListNextPendingFilesAsync(general, automaticOnly: true, ct)).ToArray());
Assert.IsEmpty(await bed.Db.Exports.ListNextPendingFilesAsync(own, automaticOnly: false, ct));
}
// The signal ---------------------------------------------------------------------------------------------------