navidrome/db
Deluan Quintão 961ee8c413
fix(scanner): keep tag numbers within the int32 range (#6202)
* fix(scanner): keep tag numbers within the int32 range

A track number of 4294967295 (-1 stored as an unsigned 32-bit tag) was saved
as-is by 64-bit builds. 32-bit builds (armv5/6/7, 386) cannot read that value
back into an int, so every scan failed with "converting driver.Value type
int64 to a int: value out of range" when loading the folder's media files.

Track and disc numbers (and their totals) are now parsed as int32 and fall
back to 0 when out of range, matching how unparseable values are handled.
BPM values outside the int32 range are dropped. A migration resets existing
out-of-range track_number, disc_number and bpm values, and removes
out-of-range keys from album.discs, so databases written by 64-bit builds are
readable again by 32-bit ones. Persistent IDs are unaffected because they use
the raw tag text.

Fixes #6200

* fix(scanner): accept the int32 minimum as a BPM value

The BPM range check compared the absolute value against MaxInt32, which
rejected -2147483648 even though it fits in an int32. Compare against
MinInt32 and MaxInt32 separately, matching atoi32 and the migration.

* fix(scanner): treat negative track, disc and BPM values as missing

Track numbers, disc numbers and BPM can never be negative, so negative tag
values now map to 0 (track/disc, including totals) or nil (BPM), the same as
unparseable ones. The migration resets existing negative values as well as the
ones above the int32 range, and keeps only album disc keys from 0 to MaxInt32.
2026-09-22 19:51:32 -04:00
..
migrations fix(scanner): keep tag numbers within the int32 range (#6202) 2026-09-22 19:51:32 -04:00
backup.go fix(cli): fail restore when the backup file does not exist instead of wiping the database (#6085) 2026-09-11 20:50:45 -04:00
backup_test.go fix(cli): fail restore when the backup file does not exist instead of wiping the database (#6085) 2026-09-11 20:50:45 -04:00
db.go feat(cli): add 'doctor' and 'search rebuild' commands to recover from FTS5 corruption (#6069) 2026-09-11 22:26:28 -04:00
db_test.go feat(bfr): Big Refactor: new scanner, lots of new fields and tags, improvements and DB schema changes (#2709) 2025-02-19 20:35:17 -05:00
export_test.go feat(cli): add 'doctor' and 'search rebuild' commands to recover from FTS5 corruption (#6069) 2026-09-11 22:26:28 -04:00
optimize.go perf(db): keep query planner statistics trustworthy with full ANALYZE (#5740) 2026-07-13 12:04:29 -04:00
optimize_test.go perf(db): keep query planner statistics trustworthy with full ANALYZE (#5740) 2026-07-13 12:04:29 -04:00
repair.go feat(cli): add 'doctor' and 'search rebuild' commands to recover from FTS5 corruption (#6069) 2026-09-11 22:26:28 -04:00
repair_test.go feat(cli): add 'doctor' and 'search rebuild' commands to recover from FTS5 corruption (#6069) 2026-09-11 22:26:28 -04:00