E4: copie del fotogramma con il loro nome, eventi che non si perdono, visualizzatore che si chiude

«Copia di nuovo» di un _fotogramma lo rifaceva come _t…, e un lavoro in attesa prendeva un istante del file vecchio.
Un'analisi copriva l'evento di una copia finita; il visualizzatore restava sopra la pagina nuova e poteva mostrare un
esito superato; la scheda Esportazione perdeva il fuoco a ogni rilettura.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 18:57:58 +01:00
1 parent 6dcaf30db6
commit 2c0cfcccf2
17 files changed
+301 -35

No files matched your search

@@ -345,6 +345,53 @@ public sealed class ExportFramesTests
Assert.HasCount(1, Fingerprint.Of(bed.Usb));
}
[TestMethod]
[DataRow(null)]
[DataRow(VideoAnalysisOutcome.Moving)]
[DataRow(VideoAnalysisOutcome.Still)]
public async Task AFrameWaitingForAFileThatChangedIsTheOneOfTheNewAnalysisOrNone(VideoAnalysisOutcome? now)
{
// The job waited (disk full) while the file was replaced: the instant was chosen on the old one, so it would save
// any frame of the new one, whatever it is.
var ct = TestContext.CancellationToken;
await using var bed = await ExportTestBed.CreateAsync();
var video = (await SaveVideoAsync(bed, bed.Marta, "984", Mp4, ".mp4")).Media[0];
var usb = await bed.GeneralAsync(ct: ct);
await bed.Db.VideoAnalyses.SetAsync(new VideoAnalysis(video.Sha256!, 1, VideoAnalysisOutcome.Still, Make.T0, TimeSpan.FromMilliseconds(400)), ct);
bed.Disk.Free = 0;
var start = await bed.CopyAsync(Frames(video, new ExportFramesRequest(FrameMode.Still, null, null, null, ExportFormat.Png)), ct);
byte[] other = [.. Mp4, 0, 0, 0, 8, (byte)'f', (byte)'r', (byte)'e', (byte)'e'];
var sha = Convert.ToHexStringLower(System.Security.Cryptography.SHA256.HashData(other));
await File.WriteAllBytesAsync(bed.Library.Layout.FullPath(bed.Marta, video.RelativePath!), other, ct);
await bed.Db.Media.UpdateAsync((await bed.Db.Media.GetAsync(video.Id, ct))! with { Sha256 = sha, Bytes = other.Length }, ct);
var at = TimeSpan.FromMilliseconds(100);
if (now is { } outcome)
{
await bed.Db.VideoAnalyses.SetAsync(new VideoAnalysis(sha, 1, outcome, Make.T0, outcome == VideoAnalysisOutcome.Still ? at : null), ct);
}
bed.Disk.Free = null;
await bed.Service.ResumeAsync([start.Runs.Single().Id], ct);
await bed.Service.WaitAsync(ct);
var run = await bed.RunAsync(start.Runs.Single().Id, ct);
Assert.AreEqual(ExportRunState.Completed, run.State, run.LastError);
var item = (await bed.ItemsAsync(start.Runs.Single().Id, ct)).Single();
if (now == VideoAnalysisOutcome.Still)
{
var copy = (await bed.Db.Exports.ListCopiesAsync(usb.Id, ct: ct)).Single();
Assert.AreEqual((ExportItemState.Copied, sha), (item.State, copy.SourceSha256), item.LastError);
Assert.AreEqual(TimeSpan.FromMilliseconds(ExportFrames.ActualMs(Locate(other, [at]).Single().Actual)), copy.FrameAt);
StringAssert.EndsWith(copy.RelativePath, "_fotogramma.png");
}
else
{
Assert.AreEqual((ExportItemState.Skipped, ExportText.Notes.NotStill), (item.State, item.Note));
StringAssert.Contains(ExportText.Note(item.Note), "Il video è cambiato");
Assert.IsEmpty(Fingerprint.Of(bed.Usb));
}
}
[TestMethod]
public async Task OnlyAStillVideoGivesItsFrameAndACopyIsAlwaysTheWholeVideo()
{