beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.9k stars 1.82k forks source link

"beet update" fails #2863

Closed gramster closed 6 years ago

gramster commented 6 years ago

Problem

I'm trying to run "beet update" but it fails, apparently while trying to move a non-existent file onto itself.

Sending event: before_item_moved
Sending event: item_moved
moving album art /volume1/music/beet/Compilations/What Women Want_ Music From the Motion Picture/cover.1.jpg to /volume1/music/beet/Compilations/What Women Want_ Music From the Motion Picture/cover.1.jpg
Traceback (most recent call last):
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/beets/util/__init__.py", line 477, in move
    os.rename(path, dest)
FileNotFoundError: [Errno 2] No such file or directory: b'/volume1/music/beet/Compilations/What Women Want_ Music From the Motion Picture/cover.1.jpg' -> b'/volume1/music/beet/Compilations/What Women Want_ Music From the Motion Picture/cover.1.jpg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/site-packages/beets/util/__init__.py", line 481, in move
    shutil.copyfile(path, dest)
  File "/volume1/@appstore/py3k/usr/local/lib/python3.5/shutil.py", line 114, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: b'/volume1/music/beet/Compilations/What Women Want_ Music From the Motion Picture/cover.1.jpg'

Error: No such file or directory while moving /volume1/music/beet/Compilations/What Women Want_ Music From the Motion Picture/cover.1.jpg to /volume1/music/beet/Compilations/What Women Want_ Music From the Motion Picture/cover.1.jpg

Setup

My configuration (output of beet config) is:

library: /volume1/music/library.db
fetchart:
    auto: yes
    cautious: yes
    cover_names: cover folder
    google_engine: 001442825323518660753:hrh5ch1gjzm
    enforce_ratio: no
    sources:
    - filesystem
    - coverart
    - itunes
    - amazon
    - albumart
    store_source: no
    maxwidth: 0
    fanarttv_key: REDACTED
    google_key: REDACTED
    minwidth: 0
scrub:
    auto: yes
directory: /volume1/music/beet

import:
    move: yes
embedart:
    auto: yes
    maxwidth: 0
    compare_threshold: 0
    ifempty: no
    remove_art_file: no
threaded: yes
lastgenre:
    fallback: ''
    source: artist
    min_weight: 10
    whitelist: yes
    prefer_specific: no
    canonical: no
    count: 1
    separator: ', '
    auto: yes
    force: yes
plugins:
- discogs
- fetchart
- embedart
- lastgenre
- scrub
- missing
- duplicates
- mbsync
scrub:
    auto: yes
duplicates:
    copy: ''
    keys: []
    checksum: ''
    merge: no
    move: ''
    count: no
    full: no
    album: no
    delete: no
    tag: ''
    strict: no
    format: ''
    tiebreak: {}
    path: no
missing:
    album: no
    total: no
    count: no
discogs:
    user_token: REDACTED
    apikey: REDACTED
    tokenfile: discogs_token.json
    source_weight: 0.5
    apisecret: REDACTED
(paste here)
sampsyo commented 6 years ago

Interesting! It looks like there are two problems:

  1. A file that beets was tracking got deleted, and update doesn't currently know how to clean up art files when they're deleted. See #2419, #2036, and https://github.com/beetbox/beets/issues/2768#issuecomment-361624969, for example.
  2. The error looks strange because we're moving a file onto itself. The bit of code that's causing this problem is supposed to be guarded by a check that we're not moving a file into the same location it came from (see the nearby call to samefile). However, that check fails if the file doesn't exist. We should probably add an extra check for path equality (just p1 == p2) to avoid weird situations like this.

Does that sound right? If so, we can quickly fix the second thing, at least.

gramster commented 6 years ago

I think it would be obviously good to fix both things :-) A quick fix of thing 2 would be a good start.

If I turn off art files in the config will beets at least just ignore them? That may be a way to at least get past this and eventually I can use Picard or something to fix the art files.

gramster commented 6 years ago

BTW I had a similar error-out when doing a merge:

Error: No such file or directory while moving /volume1/music/beet/Paul A. Schwartz/Aria 2_ New Horizon/cover.1.jpg to /volume1/music/beet/Paul A. Schwartz/Aria 2_ New Horizon/cover.1.jpg

Very annoying when these things cause beets to exit, because resuming imports doesn't seem to work well and I have to redo a lot of work.

sampsyo commented 6 years ago

Cool; I pushed a quick fix for the equal-path problem.

If you're interested in the broader problem of file errors that abort operations, please take a look at a few related issues—this has been discussed in some detail (and we could definitely use some help sorting it out).

nicolahinssen commented 6 years ago

I still have this exact issue on the latest source build.

retrography commented 5 years ago

The same issue here. I have had it since I started using beets, and it is definitely still there in the last version.