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:
parent
c86e50245e
commit
f0ac905fdb
7 changed files with 122 additions and 4 deletions
|
|
@ -145,11 +145,16 @@ func scanSingleFile(ctx context.Context, ffprobePath, filePath string, cacheIdx
|
|||
// Parse season/episode
|
||||
item.Season, item.Episode = ParseSeasonEpisode(item.FileName)
|
||||
|
||||
// Incremental: skip if file hasn't changed
|
||||
// Incremental: skip if file hasn't changed. EXCEPT a previously-damaged
|
||||
// file is always re-probed — a re-download to the same path can land with
|
||||
// an identical size+mtime (some torrent clients preserve the torrent's
|
||||
// mtime), so trusting the cached "damaged" verdict would pin a now-healthy
|
||||
// file as broken forever. Re-probing damaged items is cheap (they're few).
|
||||
if incremental && existing != nil {
|
||||
if idx, ok := cacheIdx[filePath]; ok {
|
||||
cached := existing.Items[idx]
|
||||
if cached.FileSize == item.FileSize && cached.ModTime == item.ModTime && cached.MediaInfo != nil {
|
||||
if cached.FileSize == item.FileSize && cached.ModTime == item.ModTime &&
|
||||
cached.MediaInfo != nil && cached.MediaInfo.Integrity == nil {
|
||||
item.MediaInfo = cached.MediaInfo
|
||||
return item
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue