byrongamatos and Claude Sonnet 4.6
f6e9727b04
fix(scan): refuse to prune when listing returns 0 songs and DB is non-empty
...
When background_scan() discovers zero songs in the DLC directory but the
songs table is non-empty, skip delete_missing and return with stage='error'.
An empty listing on a non-empty library almost certainly means the DLC mount
was temporarily inaccessible (FUSE remount, NTFS dirty-flag RO fallback, brief
unmount mid-scan) rather than every song being genuinely deleted.
delete_missing({}) on a non-empty DB deleted ALL rows — the #P1-libpurge
incident that wiped 50,943 songs was caused by exactly this path.
The guard fires only when current_files is empty AND the DB has at least one
row, so a genuinely empty new library is unaffected.
Test: test_scan_prune_guard.py::test_empty_listing_refuses_prune_when_db_nonempty
Failing input: dlc dir with no feedpak/sloppak/wem + 1 DB row.
Before: delete_missing({}) fires, row gone.
After: stage='error', row survives.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01H2bM5jSbMskpdxm2CmuQVj
2026-09-04 13:18:46 +02:00
..
2026-07-16 12:06:52 +02:00
2026-06-16 18:49:40 +01:00
2026-09-03 18:34:02 +02:00
2026-09-03 17:52:30 +02:00
2026-06-16 18:47:13 +02:00
2026-07-12 01:26:02 +02:00
2026-07-05 00:17:43 +02:00
2026-07-03 12:15:43 +02:00
2026-07-10 15:06:22 +02:00
2026-07-11 11:56:53 +02:00
2026-07-11 11:56:53 +02:00
2026-07-03 12:15:43 +02:00
2026-07-11 11:32:21 +02:00
2026-07-03 12:15:43 +02:00
2026-06-23 11:03:01 +02:00
2026-07-03 12:15:43 +02:00
2026-07-11 15:36:22 +02:00
2026-06-16 18:47:13 +02:00
2026-07-03 12:15:43 +02:00
2026-07-12 00:50:50 +02:00
2026-07-12 00:50:50 +02:00
2026-09-03 17:52:30 +02:00
2026-07-11 14:56:12 +02:00
2026-07-23 01:01:51 +02:00
2026-07-11 11:32:21 +02:00
2026-07-03 12:15:43 +02:00
2026-07-03 12:15:43 +02:00
2026-07-12 11:30:53 +02:00
2026-07-03 13:01:07 +02:00
2026-06-23 11:03:01 +02:00
2026-07-03 13:01:07 +02:00
2026-07-05 00:15:50 +02:00
2026-06-16 19:36:53 +01:00
2026-07-11 11:32:21 +02:00
2026-07-11 16:33:03 +02:00
2026-07-15 21:23:10 +02:00
2026-07-13 16:53:06 +02:00
2026-07-05 21:09:38 +02:00
2026-06-23 11:03:01 +02:00
2026-07-02 08:40:20 +02:00
2026-07-07 23:58:49 +02:00
2026-07-05 00:20:31 +02:00
2026-07-19 00:56:32 -05:00
2026-07-10 13:12:10 +02:00
2026-07-19 01:36:28 -05:00
2026-07-05 20:08:19 +02:00
2026-07-03 12:15:43 +02:00
2026-06-16 18:47:13 +02:00
2026-07-10 21:12:54 +02:00
2026-07-21 13:27:41 +02:00
2026-07-10 21:12:54 +02:00
2026-07-10 21:12:54 +02:00
2026-07-07 23:57:20 +02:00
2026-07-03 12:15:43 +02:00
2026-07-03 12:15:43 +02:00
2026-07-19 00:04:30 -05:00
2026-07-19 00:04:30 -05:00
2026-06-16 18:47:13 +02:00
2026-06-23 11:03:01 +02:00
2026-07-10 19:16:01 +02:00
2026-07-03 12:15:43 +02:00
2026-07-19 00:04:30 -05:00
2026-07-14 01:58:24 -04:00
2026-06-16 19:36:53 +01:00
2026-07-11 11:32:21 +02:00
2026-07-05 01:11:38 +02:00
2026-07-07 23:58:49 +02:00
2026-07-07 10:27:45 +02:00
2026-07-07 10:27:17 +02:00
2026-07-13 12:22:42 -04:00
2026-07-03 12:15:43 +02:00
2026-06-16 18:47:13 +02:00
2026-07-19 00:40:08 -05:00
2026-06-16 18:47:13 +02:00
2026-07-10 17:16:34 +02:00
2026-06-23 11:03:01 +02:00
2026-07-10 20:16:22 +02:00
2026-07-19 00:10:53 -05:00
2026-07-12 00:29:48 +02:00
2026-06-23 11:03:01 +02:00
2026-07-11 22:44:03 +02:00
2026-07-12 00:19:59 +02:00
2026-07-12 00:29:48 +02:00
2026-07-03 12:15:43 +02:00
2026-07-03 12:15:43 +02:00
2026-06-16 18:47:13 +02:00
2026-07-12 00:50:50 +02:00
2026-09-03 13:57:19 +02:00
2026-07-14 19:48:39 +02:00
2026-06-16 18:47:13 +02:00
2026-09-04 13:18:46 +02:00
2026-07-11 11:32:21 +02:00
2026-07-12 01:26:02 +02:00
2026-07-11 12:35:05 +02:00
2026-07-11 12:35:05 +02:00
2026-07-05 00:16:42 +02:00
2026-06-16 18:47:13 +02:00
2026-07-03 12:15:43 +02:00
2026-07-21 13:27:41 +02:00
2026-06-16 18:47:13 +02:00
2026-06-20 21:59:04 +02:00
2026-07-11 15:36:22 +02:00
2026-07-13 12:22:42 -04:00
2026-06-20 14:10:04 -07:00
2026-06-20 21:23:48 +02:00
2026-06-16 18:47:13 +02:00
2026-07-23 11:27:21 +02:00
2026-06-20 21:35:07 +02:00
2026-07-23 11:27:21 +02:00
2026-07-13 17:13:08 +02:00
2026-07-19 11:45:16 -04:00
2026-06-16 18:47:13 +02:00
2026-07-13 15:36:05 +02:00
2026-07-03 12:15:43 +02:00
2026-07-21 13:30:54 +02:00
2026-07-02 20:51:57 +02:00
2026-07-13 13:25:44 +02:00
2026-07-03 12:15:43 +02:00
2026-07-12 01:32:46 +02:00
2026-06-23 11:03:01 +02:00
2026-07-12 13:25:16 +02:00
2026-07-23 11:27:21 +02:00
2026-07-21 13:27:41 +02:00
2026-07-12 15:24:39 -05:00
2026-07-03 12:15:43 +02:00
2026-06-16 18:47:13 +02:00
2026-07-03 12:15:43 +02:00
2026-07-03 12:15:43 +02:00
2026-07-03 12:15:43 +02:00
2026-07-10 21:30:53 +02:00
2026-07-22 15:45:56 -04:00
2026-06-16 18:47:13 +02:00