CubeComming #804: importing Coldplay "Yellow" (the 269s Parachutes album track, correctly tagged) was quarantined — "Duration mismatch: file is 269.2s, expected 266.0s (drift 3.2s > tolerance 3.0s)". The expected 266s came from a re-resolved *single* edition, not the file's actual album. The duration-agreement integrity check exists to catch truncated/wrong slskd TRANSFERS — but a manual import is the user's own already-tagged file being sorted, so checking it against a re-resolved release just manufactures false quarantines. Fix: both manual-import paths (singles + album) now mark the context is_local_import; the integrity check skips the duration-agreement leg for local imports via expected_duration_for_check() (new pure helper). The size + mutagen-parse legs still run, so genuinely broken files are still caught — only the release-vs-file duration comparison is skipped, and only for manual imports. slskd downloads are completely unaffected. This does NOT change the deeper matching (file still groups under Singles vs the Parachutes album — the #767 canonical-version family); it stops the false quarantine so the file imports. Tests: 4 on the helper (local skips, download keeps, zero/None/garbage, string coercion) + updated the routes context assertion. 557 import/integrity tests pass.
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
"""Duration-agreement leg is skipped for local/manual imports (#804).
|
|
|
|
The duration check catches truncated/wrong slskd downloads. A manual import is
|
|
the user's own file being sorted — duration-agreeing it against a re-resolved
|
|
release false-quarantines (Coldplay 'Yellow' album file vs a single's length).
|
|
"""
|
|
|
|
from core.imports.file_integrity import expected_duration_for_check
|
|
|
|
|
|
def test_local_import_skips_duration_leg():
|
|
# Even with a valid expected duration, a local import returns None (skip).
|
|
assert expected_duration_for_check(266000, is_local_import=True) is None
|
|
|
|
|
|
def test_download_keeps_expected_duration():
|
|
assert expected_duration_for_check(266000, is_local_import=False) == 266000
|
|
|
|
|
|
def test_zero_or_missing_expected_is_none():
|
|
assert expected_duration_for_check(0, is_local_import=False) is None
|
|
assert expected_duration_for_check(None, is_local_import=False) is None
|
|
assert expected_duration_for_check("nan", is_local_import=False) is None
|
|
|
|
|
|
def test_string_numeric_expected_coerced():
|
|
assert expected_duration_for_check("266000", is_local_import=False) == 266000
|