0.6.14: Fix Bandcamp sync silently failing to import new purchases
sync-bandcamp.sh set a hardcoded PATH at startup that left out /opt/venv/bin, which is where beet lives in this image. Every time the Bandcamp sync had a new purchase to import, its call into import-track.sh would run beet import with that broken PATH, fail with "command not found", and import-track.sh would just log the exit code and carry on, so sync-bandcamp.sh still reported success. The purchase sat on disk, never entered the beets library, and never showed up in Navidrome. This went unnoticed for weeks because most daily syncs have nothing new to import, so the broken code path rarely ran. Fixed the same copy-pasted PATH line in upgrade-mp3-to-flac.sh (which also calls beet directly) and notify-telegram.sh (harmless there, but fixed for consistency). Also moved the post-import duplicate cleanup (replace-with-better.sh and dedup-library.sh) out of sync-bandcamp.sh and into import-track.sh itself, so every import gets the same cleanup, not just Bandcamp purchases. A manual import or SMB drop that happens to match something already in the library no longer leaves a duplicate copy sitting there until someone runs the dedup review by hand.
This commit is contained in:
@@ -242,6 +242,30 @@ BEETS_EXIT=0
|
||||
beet import -q -s "$DEST_DIR" >> "$LOG" 2>&1 || BEETS_EXIT=$?
|
||||
log "beets import finished with exit code $BEETS_EXIT"
|
||||
|
||||
# ==== Safety net: clean up stragglers + exact duplicates ====
|
||||
# With duplicate_action=keep, beets always imports rather than rejecting a
|
||||
# real conflict (see beets/config.yaml) -- any file whose (albumartist,
|
||||
# album, title) already exists in the library gets imported anyway as a
|
||||
# `.1.ext` sibling. That's true whether this run came from the web UI, an
|
||||
# SMB drop, or sync-bandcamp.sh, so the cleanup has to run here rather than
|
||||
# per-caller (a 2026-07-23 incident: a Bandcamp sync's own call into this
|
||||
# script failed and silently stranded ~150 already-owned files in import-me/
|
||||
# for two weeks; a later unrelated manual import swept them back in and
|
||||
# duplicated them, and nothing had deduped since).
|
||||
log "Running replace-with-better safety pass on /downloads stragglers"
|
||||
if ${PIPELINE_DIR:-/app/pipeline}/lib/replace-with-better.sh --apply >> "$LOG" 2>&1; then
|
||||
log "replace-with-better OK"
|
||||
else
|
||||
log "WARN: replace-with-better.sh exited non-zero (exit $?)"
|
||||
fi
|
||||
|
||||
log "Running dedup pass (exact-match duplicates only; FLAC > MP3, then largest file)"
|
||||
if ${PIPELINE_DIR:-/app/pipeline}/lib/dedup-library.sh --apply >> "$LOG" 2>&1; then
|
||||
log "dedup OK"
|
||||
else
|
||||
log "WARN: dedup-library.sh exited non-zero (exit $?)"
|
||||
fi
|
||||
|
||||
# ==== Regenerate M3U if playlist was specified ====
|
||||
if [[ -n "$PLAYLIST_NAME" ]]; then
|
||||
log "Regenerating M3U for $PLAYLIST_NAME"
|
||||
|
||||
Reference in New Issue
Block a user