fix(engine): cross-backend integrity guard with retry-then-damaged
A truncated debrid download (in-memory byte counter hit 100% while the
NFS write-back silently dropped most of the bytes) was marked completed.
The 1.1.6 fsync fix closed the debrid-specific hole; this generalizes the
guarantee so "completed" never means a corrupt file on ANY backend.
- IntegrityError + bounded retry: on a corrupt/short result the manager
re-downloads the same source up to 3x (clean start), then surfaces the
task as damaged ("corrupt download:" prefix) instead of completing it.
- verify (size mismatch / empty), debrid (incomplete / post-write / flush),
torrent (BytesMissing), usenet (par2 unrepairable / repair-failed) all
classify integrity failures so they route through the retry/damaged path.
- scanner: a file ffprobe can't read is emitted as a damaged library_item
(reason "unreadable") instead of being silently dropped from the sync.
- tests: manager retry-then-success + retry-exhausted-then-damaged,
verifying->resolving transition, damaged sync item.
This commit is contained in:
parent
271413e0f9
commit
a5f3f0914a
13 changed files with 400 additions and 91 deletions
|
|
@ -29,14 +29,19 @@ func verify(result *Result) error {
|
|||
}
|
||||
|
||||
if actualSize == 0 {
|
||||
return fmt.Errorf("download is empty: %s", result.FilePath)
|
||||
// Integrity, not transport: a zero-byte result is corrupt — let the manager
|
||||
// re-download clean rather than surface an empty file as completed.
|
||||
return integrityErr("empty", "download is empty: %s", result.FilePath)
|
||||
}
|
||||
|
||||
// If we know the expected size, check within 2% tolerance
|
||||
// If we know the expected size, check within 2% tolerance (container/muxing
|
||||
// overhead). A shortfall beyond that is a truncated/corrupt file — classify it
|
||||
// as an IntegrityError so the manager re-downloads clean instead of completing
|
||||
// a half file (the last line of defense across every backend).
|
||||
if result.Size > 0 {
|
||||
tolerance := int64(float64(result.Size) * 0.02)
|
||||
if actualSize < result.Size-tolerance {
|
||||
return fmt.Errorf("size mismatch: expected %d, got %d", result.Size, actualSize)
|
||||
return integrityErr("size_mismatch", "size mismatch: expected %d, got %d", result.Size, actualSize)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue