soulsync/core/imports
Broque Thomas 46d8e15674 Prune slskd dedup orphans after import
slskd appends "_<19-digit unix-nanosecond timestamp>" to a downloaded
filename when the destination already contains a same-named file
(concurrent downloads of the same track, partial-file retries after a
connection drop, cancelled-then-redownloaded files, the same track
surfacing in multiple synced playlists). The file-finder code already
recognized the suffix when matching a download to its source — but
after the canonical file moved into the library, the leftover
"_<timestamp>" siblings sat orphaned in the downloads folder forever.

Reported on Discord by Shdjfgatdif.

cleanup_slskd_dedup_siblings() runs at the end of each successful
import (3 safe_move_file sites in pipeline.py) and prunes any
remaining siblings that strip down to the canonical stem with the
same extension. Conservative match (>= 18 trailing digits) keeps
legitimate filenames like "Track 5" and "Album 1995" untouched. Per-
file unlink failures are swallowed so a single locked file doesn't
block the rest.

17 regression tests cover the suffix-strip primitive, orphan removal,
no-op cases, mismatched extensions, subdirectories, and partial-failure
recovery.
2026-05-01 09:35:08 -07:00
..
__init__.py Rehome import helpers into core/imports 2026-04-27 19:54:44 +03:00
album.py Rehome import helpers into core/imports 2026-04-27 19:54:44 +03:00
album_naming.py Rehome import helpers into core/imports 2026-04-27 19:54:44 +03:00
context.py Route imported singles/EPs through album_path template 2026-04-30 21:33:09 -07:00
file_ops.py Prune slskd dedup orphans after import 2026-05-01 09:35:08 -07:00
filename.py Rehome import helpers into core/imports 2026-04-27 19:54:44 +03:00
guards.py Tighten metadata and import safety 2026-04-27 20:28:05 +03:00
paths.py fix: substitute \$cdnum in download paths and skip auto disc folder when template uses it 2026-04-28 21:32:24 -07:00
pipeline.py Prune slskd dedup orphans after import 2026-05-01 09:35:08 -07:00
resolution.py Move metadata helpers into package modules 2026-04-29 11:28:42 +03:00
side_effects.py Extract wishlist logic into dedicated package 2026-04-28 21:17:24 +03:00
staging.py Fix single import source handling 2026-04-27 19:54:45 +03:00