Files
alembic/pipeline/lib
andrew ade32c4d0c Harden replace-with-better.sh under set -eu (R1)
Adds strict mode to the file-replacement script (the destructive path used by
the Bandcamp sync and the mp3->flac upgrade).

Uses `set -eu` deliberately WITHOUT pipefail: the script reads tags through
many `cmd | head -1` pipelines, and under pipefail `head` closing the pipe
early makes the producer die with SIGPIPE, turning good reads into false
failures. pipefail adds no safety here since every piped read feeds a value
that is immediately emptiness-checked.

Guards added so a single expected non-zero doesn't abort a destructive run:
- the four progressive `beet ls` match queries fall through on empty/error
- beet remove / beet import / rm / leftover-import / find -delete log a warning
  instead of aborting mid-replace
- copy_tags_from_existing is called with `|| true` (also suspends set -e for its
  best-effort per-tag metaflac calls)
- explicit `exit 0` so a successful run reports success

Verified: function-level tests (ranking, match fall-through under failing beet)
and a full dry-run against the real library, all exit 0 under set -e.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-10 10:23:01 -06:00
..