E3: seconda revisione di rimuxaggio, spazio, impostazioni e zip
verifica / controlli (push) Canceled after 0s
verifica / prove (push) Canceled after 0s
verifica / installatore (push) Canceled after 0s
verifica / immagine (push) Canceled after 0s

Le quattro osservazioni confermate della seconda revisione, ognuna con
la sua prova (ciascuna cade sul codice di prima):

- Rimuxaggio con fotogrammi B: l'MP4 misura la fine della presentazione
  in tempo di composizione, non con la somma delle durate di decodifica.
  Prima nascondeva gli ultimi fotogrammi mostrati (2 in un iPhone) e
  durava altrettanto meno in elst, tkhd e mvhd. Per le tracce senza
  scarti di composizione i byte restano gli stessi.
- Conversione della libreria: il lavoro ricorda il file che l'ha messo
  in pausa per spazio e quanto serve al suo convertito. Finché il disco
  non ha posto anche per quello, non rilegge l'originale a ogni
  risveglio (anche quando lo spazio libero sta appena sopra la soglia).
- Impostazioni dell'esportazione: formati, chiavi «dal» e coda del
  formato sostituito si salvano in una transazione sola; «Anche i N»
  dopo il salvataggio non dipende più dalla richiesta. Il gancio della
  libreria legge formati e chiavi «dal» in una lettura. Una scheda
  chiusa o un arresto non lasciano più un formato senza la sua chiave
  né «Non riuscito» che «Riprova» non tocca.
- Zip dei fotogrammi: i tempi del blocco passano da un TimeProvider
  della BCL, e la prova del lettore lento non dipende più dal carico
  della macchina.

Decisioni in docs/decisioni.md (28/11).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-28 14:29:00 +01:00
1 parent 958cb71cd6
commit 2efb408957
13 files changed
+459 -49

No files matched your search

+4 -3
View File
@@ -689,8 +689,9 @@ public static class ExportApi
throw new BadRequestException("Niente da salvare: scegli un'impostazione.");
}
await after.SaveAsync(storage.Settings, ct).ConfigureAwait(false);
await queue.OnSettingsChangedAsync(before, after, ct).ConfigureAwait(false);
// The formats, their «dal» keys and the queue of a format replaced in one transaction; once it is stored, what
// follows no longer depends on the request (a closed tab must not leave half of it).
await queue.SaveSettingsAsync(before, after, ct).ConfigureAwait(false);
if (body.ConvertExisting == true)
{
// «Anche i N già in libreria» answers the question about the kind being changed: the other kind keeps
@@ -699,7 +700,7 @@ public static class ExportApi
var video = Changed(MediaKind.Video, body.LibraryVideoFormat, before, after);
if (photo is not null || video is not null)
{
queued = await queue.EnqueueExistingAsync(photo, video, ct).ConfigureAwait(false);
queued = await queue.EnqueueExistingAsync(photo, video, CancellationToken.None).ConfigureAwait(false);
}
}
+7 -4
View File
@@ -77,6 +77,9 @@ public sealed class FrameService(IClock clock)
/// </summary>
public TimeSpan WriteStall { get; init; } = TimeSpan.FromSeconds(60);
/// <summary>The timers of <see cref="WriteStall"/> (a seam: a test moves their time only as its link sends).</summary>
public TimeProvider StallTime { get; init; } = TimeProvider.System;
/// <summary>What a video allows, from the cache by SHA-256 when known (the file is opened only the first time).</summary>
public async Task<VideoFrameInfo> InfoAsync(string path, string? sha256, CancellationToken ct)
{
@@ -203,7 +206,7 @@ public sealed class FrameService(IClock clock)
ArgumentNullException.ThrowIfNull(output);
ArgumentNullException.ThrowIfNull(plan);
var image = MediaConverter.ImageFormatOf(plan.Format) ?? throw new ArgumentException("Formato del fotogramma non valido.", nameof(plan));
var guarded = new StallGuardStream(output, WriteStall);
var guarded = new StallGuardStream(output, WriteStall, StallTime);
var names = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var zip = await ZipArchive.CreateAsync(guarded, ZipArchiveMode.Create, leaveOpen: true, entryNameEncoding: null, ct).ConfigureAwait(false);
await using (zip.ConfigureAwait(false))
@@ -369,7 +372,7 @@ public sealed class FrameService(IClock clock)
/// .NET 10 writes the small data descriptor of each entry synchronously even through its asynchronous API: those
/// bytes are kept here and sent with the next asynchronous write, so the response never sees a synchronous write.
/// </summary>
private sealed class StallGuardStream(Stream inner, TimeSpan stall) : Stream
private sealed class StallGuardStream(Stream inner, TimeSpan stall, TimeProvider time) : Stream
{
// A data descriptor is 16 or 24 bytes; anything far larger written synchronously is a change of the BCL.
private const int MaxPending = 64 * 1024;
@@ -459,8 +462,8 @@ public sealed class FrameService(IClock clock)
{
for (var offset = 0; offset < buffer.Length; offset += Piece)
{
using var guard = CancellationTokenSource.CreateLinkedTokenSource(ct);
guard.CancelAfter(stall);
using var timer = new CancellationTokenSource(stall, time);
using var guard = CancellationTokenSource.CreateLinkedTokenSource(ct, timer.Token);
await inner.WriteAsync(buffer.Slice(offset, Math.Min(Piece, buffer.Length - offset)), guard.Token).ConfigureAwait(false);
}
}