Importazione e dati: «Tieni il più grande» per gruppi, righe di _febe.jsonl mai perse, ricostruzione robusta (import-1, import-2, library-1, journal-1, rebuild-1, rebuild-2, rebuild-3, backup-1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
Claude committed 2026-10-14 00:53:10 +00:00
1 parent 78c92eb2a4
commit 628fe5db2b
13 files changed
+1145 -95

No files matched your search

@@ -89,6 +89,35 @@ public sealed class MediaReaderTests
Assert.IsNull(Mp4Reader.Read(new MemoryStream("not a movie at all"u8.ToArray()), Now));
}
/// <summary>
/// A 64-bit box size close to 2^63 overflows «offset + size»: the reader must stop on it, not walk backwards
/// forever (the analysis would hang and every «Riprendi» would hit the same file again).
/// </summary>
[TestMethod]
public void AHugeSixtyFourBitBoxSizeEndsTheReadingInsteadOfLooping()
{
static byte[] Box(string type, params byte[][] parts) =>
[.. BigEndian((uint)(8 + parts.Sum(p => p.Length))), .. Encoding.ASCII.GetBytes(type), .. parts.SelectMany(p => p)];
static byte[] BigEndian(uint value) => [(byte)(value >> 24), (byte)(value >> 16), (byte)(value >> 8), (byte)value];
byte[] huge = [0, 0, 0, 1, .. "xxxx"u8, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8];
var ftyp = Box("ftyp", "isom"u8.ToArray(), [0, 0, 2, 0]);
// Inside moov: a valid «free» box, then the damaged one.
byte[] insideMoov = [.. ftyp, .. Box("moov", Box("free"), huge)];
// At the top level, after ftyp.
byte[] topLevel = [.. ftyp, .. huge, .. new byte[32]];
foreach (var (name, bytes) in new[] { ("moov", insideMoov), ("primo livello", topLevel) })
{
var reading = Task.Run(() => Mp4Reader.Read(new MemoryStream(bytes), Now));
Assert.IsTrue(reading.Wait(TimeSpan.FromSeconds(10)), $"{name}: la lettura deve finire.");
var info = reading.Result;
Assert.IsNull(info?.CreatedAt, name);
Assert.IsNull(info?.Width, name);
}
}
[TestMethod]
public void AnMp4MadeByFfmpegCarriesItsCreationTime()
{