feat(library): detect corrupt/incomplete files during scan

ffprobe already runs on every scanned file; now we capture its stderr and
assess integrity from it. assessIntegrity flags a file "damaged" on the
markers that mean the container/bitstream is unusable: invalid_data,
ebml_corrupt, moov_missing, bitstream_corrupt, plus no_duration (a video
stream with non-positive duration = a truncated/incomplete download).

The verdict rides on MediaInfo.Integrity (IntegrityInfo{Damaged,Reason}),
maps onto LibrarySyncItem.{Integrity,IntegrityReason}, and syncs to the web
so a damaged file can be surfaced at rest instead of only blowing up at
playback.

Bumps the scan cache version (1 → 2) so existing entries re-probe once, and
the scanner re-probes any cached entry that has no integrity verdict yet.
This commit is contained in:
Deivid Soto 2026-06-02 19:42:00 +02:00
parent c86e50245e
commit f0ac905fdb
7 changed files with 122 additions and 4 deletions

View file

@ -338,6 +338,11 @@ type LibrarySyncItem struct {
AudioTracks any `json:"audioTracks,omitempty"`
SubtitleTracks any `json:"subtitleTracks,omitempty"`
VideoInfo any `json:"videoInfo,omitempty"`
// Integrity flags a damaged / incompletely-downloaded file ("damaged" or
// empty). IntegrityReason is a stable code (ebml_corrupt, moov_missing,
// no_duration, …) the web maps to a localized "re-download" message.
Integrity string `json:"integrity,omitempty"`
IntegrityReason string `json:"integrityReason,omitempty"`
}
// LibrarySyncResponse is returned after syncing library items.