diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-07-01 15:56:48 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-07-01 15:56:48 +0900 |
| commit | 7b71c4f927f6f8f891e4175423af8ecf927ce6c3 (patch) | |
| tree | c47ccafbb3f14508df7cad6115b0869c8177d448 | |
| parent | 17aadcf0d412bff43f70b7a181ecce0a23748ff5 (diff) | |
fix(qndl-artist): bound apply prune to album/artist dirs, clean temp on move fail
| -rwxr-xr-x | ar/.local/bin/qndl-artist | 7 | ||||
| -rw-r--r-- | ar/.local/bin/tests/test-qndl-artist.sh | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/ar/.local/bin/qndl-artist b/ar/.local/bin/qndl-artist index c79a966..1be0939 100755 --- a/ar/.local/bin/qndl-artist +++ b/ar/.local/bin/qndl-artist @@ -40,13 +40,14 @@ cmd_apply() { fi mkdir -p "$_destdir" mv "$_fp" "$_dest" || return 1 - # 빈 원본 앨범/아티스트 폴더 정리 - rmdir -p "$MUSIC/$_artist_seg/$(dirname "$_subpath")" 2>/dev/null || true + # 빈 원본 앨범/아티스트 폴더 정리 (MUSIC 루트는 지우지 않음) + rmdir "$MUSIC/$_artist_seg/$(dirname "$_subpath")" 2>/dev/null || true + rmdir "$MUSIC/$_artist_seg" 2>/dev/null || true _fp="$_dest" fi _tmp="$(dirname "$_fp")/.qndl-tag-$$.mp3" if ffmpeg -v error -y -i "$_fp" -map 0 -c copy -metadata album_artist="$_canon" "$_tmp" 2>/dev/null; then - mv "$_tmp" "$_fp" + mv "$_tmp" "$_fp" || { rm -f "$_tmp"; return 1; } else rm -f "$_tmp" printf 'apply: tag failed: %s\n' "$_fp" >&2 diff --git a/ar/.local/bin/tests/test-qndl-artist.sh b/ar/.local/bin/tests/test-qndl-artist.sh index cd83568..327e3fb 100644 --- a/ar/.local/bin/tests/test-qndl-artist.sh +++ b/ar/.local/bin/tests/test-qndl-artist.sh @@ -39,4 +39,9 @@ mkmp3 "$XDG_MUSIC_DIR/Dupe/Al/x.mp3" "$BIN" apply "$XDG_MUSIC_DIR/DUPE/Al/x.mp3" "Dupe" 2>/dev/null eq "apply: conflict keeps source" "yes" "$([ -f "$XDG_MUSIC_DIR/DUPE/Al/x.mp3" ] && echo yes || echo no)" +# regression: 프루닝이 MUSIC 루트를 삭제하지 않음 +SOLO="$(mktemp -d)/Music"; mkdir -p "$SOLO" +( export XDG_MUSIC_DIR="$SOLO"; mkmp3 "$SOLO/Solo/Al/s.mp3"; "$BIN" apply "$SOLO/Solo/Al/s.mp3" "SoloCanon" ) +eq "apply: prune keeps MUSIC root" "yes" "$([ -d "$SOLO" ] && echo yes || echo no)" + exit $FAIL |
