Skip to content

fix double deletion problem of source files when import_delete is set - #2

Merged
sampsyo merged 2 commits into
beetbox:masterfrom
mdecker:master
Apr 3, 2011
Merged

fix double deletion problem of source files when import_delete is set #2
sampsyo merged 2 commits into
beetbox:masterfrom
mdecker:master

Conversation

@mdecker

@mdecker mdecker commented Apr 3, 2011

Copy link
Copy Markdown

Hi,
commit 6baf9f5 introduced a bug when setting import_delete where it would try to delete the files two times
in a row - which obviously ends in a stack trace. cd18d7a should fix this.

Michael

mdecker added 2 commits April 3, 2011 18:43
…t available

the musicbrainz DB does not contain artist names for compilations,
example: release ID 762fb051-f435-4c67-895c-6e859f4cdc05
@sampsyo
sampsyo merged commit c96335b into beetbox:master Apr 3, 2011
@sampsyo

sampsyo commented Apr 3, 2011

Copy link
Copy Markdown
Member

Thanks for the fixes. I've merged both of these and added tests.

That double-delete bug was pretty embarrassing! Good thing it wasn't mine. :)

@mdorman mdorman mentioned this pull request Nov 10, 2017
eran132 added a commit to eran132/beets that referenced this pull request May 4, 2018
sampsyo pushed a commit that referenced this pull request Jun 22, 2019
Merge with head repository
adamjakab pushed a commit to adamjakab/Beets that referenced this pull request Mar 15, 2020
snejus added a commit that referenced this pull request Nov 23, 2024
Fixes #5148. 

When importing, the code that matches tracks does not consider the
medium number. This causes problems on Hybrid SACDs (and other releases)
where the artists, track numbers, titles, and lengths are the same on
both layers.

I added a distance penalty for mismatching medium numbers.

Before:

```
$ beet imp .

/Volumes/Music/ti/Red Garland/1958 - All Mornin' Long - 1 (6 items)

  Match (95.4%):
  The Red Garland Quintet - All Mornin' Long
  ≠ media, year
  MusicBrainz, 2xHybrid SACD (CD layer), 2013, US, Analogue Productions, CPRJ 7130 SA, mono
  https://musicbrainz.org/release/6a584522-58ea-470b-81fb-e60e5cd7b21e
  * Artist: The Red Garland Quintet
  * Album: All Mornin' Long
  * Hybrid SACD (CD layer) 1
     ≠ (#2-1) All Mornin' Long (20:21) -> (#1-1) All Mornin' Long (20:21)
     ≠ (#2-2) They Can't Take That Away From Me (10:24) -> (#1-2) They Can't Take That Away From Me (10:27)
     ≠ (#2-3) Our Delight (6:23) -> (#1-3) Our Delight (6:23)
  * Hybrid SACD (CD layer) 2
     ≠ (#1-1) All mornin' long (20:21) -> (#2-1) All Mornin' Long (20:21)
     ≠ (#1-2) They can't take that away from me (10:27) -> (#2-2) They Can't Take That Away From Me (10:25)
     ≠ (#1-3) Our delight (6:23) -> (#2-3) Our Delight (6:23)
➜ [A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort, eDit, edit Candidates?
```

Note that all tracks tagged with disc 1 get moved to disc 2 and vice
versa.

After:

```
$ beet-test imp .

/Volumes/Music/ti/Red Garland/1958 - All Mornin' Long - 1 (6 items)

  Match (95.4%):
  The Red Garland Quintet - All Mornin' Long
  ≠ media, year
  MusicBrainz, 2xMedia, 2013, US, Analogue Productions, CPRJ 7130 SA, mono
  https://musicbrainz.org/release/6a584522-58ea-470b-81fb-e60e5cd7b21e
  * Artist: The Red Garland Quintet
  * Album: All Mornin' Long
  * Hybrid SACD (CD layer) 1
     ≠ (#1-1) All mornin' long (20:21) -> (#1-1) All Mornin' Long (20:21)
     ≠ (#1-2) They can't take that away from me (10:27) -> (#1-2) They Can't Take That Away From Me (10:27)
     ≠ (#1-3) Our delight (6:23) -> (#1-3) Our Delight (6:23)
  * Hybrid SACD (SACD layer) 2
     * (#2-1) All Mornin' Long (20:21)
     * (#2-2) They Can't Take That Away From Me (10:24)
     * (#2-3) Our Delight (6:23)
➜ [A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort, eDit, edit Candidates?
```

Yay!
snejus added a commit that referenced this pull request Nov 23, 2024
snejus added a commit that referenced this pull request May 17, 2026
Fixes #6601 

Added `import contextvars` and changed `_extend_pipeline` to capture the
current context and run the inner pipeline within it to ensure the
`music_dir` context variable is available when the inner pipeline
resolves paths, preventing the relative-path bug that caused could not
get filesize errors and removing 0 old duplicated items during merge.

Works perfectly after the fix:

```bash
arsaboo@arsmusic:~$ beet import -m -I -t ~/shared/music/ --set genre="Filmi" --search-id 7MwKD3kEFMov4LQqyhnmzL

/home/arsaboo/shared/music (1 items)

  Match (75.2%):
  King - Lukkhe
  ≠ artist, tracks
  Spotify, None, 2026, None, Warner Music India, None, None
  https://open.spotify.com/album/7MwKD3kEFMov4LQqyhnmzL
  ≠ Artist: King; OAFF; Savera; Sunny M.R. -> King
  * Album: Lukkhe
     ≠ (#2) Khamoshiyaan (3:03) -> (#2) Khamoshiyaan (feat. Romy & Manreet Khara) (3:03)
Missing tracks (13/14 - 92.9%):
 ! Bulletproof (#1) (3:09)
 ! Jee Lenge (#3) (3:25)
 ! Headshot (#4) (3:10)
 ! Ruh Teri (feat. Manreet Khara & Agrim Joshi) (#5) (2:31)
 ! Roobaroo (#6) (3:17)
 ! Savere (#7) (2:29)
 ! Haal (#8) (3:29)
 ! Haal (The Journey) (#9) (6:13)
 ! Nachdi Shaam (#10) (2:22)
 ! Hoga Bada Mera Naam (#11) (1:58)
 ! All Eyes On Us (#12) (3:13)
 ! Swan Song (Hoya Azaad) (#13) (3:17)
 ! Bhaari Pangey (#14) (2:19)
➜ [A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort, eDit, edit Candidates, Print tracks,
Open files with Picard? a
This album is already in the library!
Old: 3 items, MP3, 320kbps, 9:45, 22.9 MiB
New: 1 items, MP3, 320kbps, 3:03, 7.8 MiB
➜ [S]kip new, Keep all, Remove old, Merge all? m

/home/arsaboo/shared/music
/data/music/Hindi Music/L/Lukkhe [30718] (2026)/Lukkhe (2026) - Bulletproof.mp3
/data/music/Hindi Music/L/Lukkhe [30718] (2026)/Lukkhe (2026) - Headshot.mp3
/data/music/Hindi Music/L/Lukkhe [30718] (2026)/Lukkhe (2026) - Jee Lenge.mp3 (4 items)

  Match (82.6%):
  King - Lukkhe
  ≠ artist, tracks
  Spotify, None, 2026, None, Warner Music India, None, None
  https://open.spotify.com/album/7MwKD3kEFMov4LQqyhnmzL
  ≠ Artist: OAFF; Savera; Ruaa Kayy; Romy; Manreet Khara -> King
  * Album: Lukkhe
     * (#1) Bulletproof (3:09)
     ≠ (#2) Khamoshiyaan (3:03) -> (#2) Khamoshiyaan (feat. Romy & Manreet Khara) (3:03)
     * (#3) Jee Lenge (3:25)
     * (#4) Headshot (3:10)
Missing tracks (10/14 - 71.4%):
 ! Ruh Teri (feat. Manreet Khara & Agrim Joshi) (#5) (2:31)
 ! Roobaroo (#6) (3:17)
 ! Savere (#7) (2:29)
 ! Haal (#8) (3:29)
 ! Haal (The Journey) (#9) (6:13)
 ! Nachdi Shaam (#10) (2:22)
 ! Hoga Bada Mera Naam (#11) (1:58)
 ! All Eyes On Us (#12) (3:13)
 ! Swan Song (Hoya Azaad) (#13) (3:17)
 ! Bhaari Pangey (#14) (2:19)
➜ [A]pply, More candidates, Skip, Use as-is, as Tracks, Group albums,
Enter search, enter Id, aBort, eDit, edit Candidates, Print tracks,
Open files with Picard? a
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants