beetbox / beets

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

Beet move unable to find files, creating incorrect album names #5079

Open Runeii opened 8 months ago

Runeii commented 8 months ago

I'm trying to move my Beets library from /music to /Incoming, using: beet -vv move -d /incoming

This ran for the first couple of hundred tracks, but then has started to fail for all tracks. The command complains that there is "No such file or directory": b'/music/Actress/R.I.P/01 - R.I.P_.mp3', but I can confirm this does exist and is not behind any restricted permissions.

Weirder, it seems to be creating weirdly named folders in the output directory:

root@84de8ff30abe:/incoming/Actress# ls
 88   Ghettoville  'Grey Over Blue'  'Hazyville [15090]'  'Hazyville [15091]'  'R.I.P. [15092]'  'R.I.P. [15093]'

To confirm, in the above example, the source folder has a single directory for the albums Hazyville and R.I.P – and neither is suffixed with numbers in square brackets.

On the chance it was this single artist, I ran beet rm Actress and tried to continue the task, but it instead complains about the first track after this artist.

Problem

Running this command in verbose (-vv) mode:

$ beet -vv (... paste here ...)

Led to this problem:

Moving 44031 items (613 already in place).
moving: /incoming/The KLF/01 -.2.mp3
Sending event: before_item_moved
Sending event: item_moved
Sending event: database_change
Sending event: database_change
moving: /incoming/The KLF/03 -.2.mp3
Sending event: before_item_moved
Sending event: item_moved
Sending event: database_change
Sending event: database_change
moving: /music/Actress/R.I.P/01 - R.I.P_.mp3
Sending event: before_item_moved
Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/beets/util/__init__.py", line 496, in move
    os.replace(path, dest)
OSError: [Errno 18] Cross-device link: b'/music/Actress/R.I.P/01 - R.I.P_.mp3' -> b'/incoming/Actress/R.I.P. [15093]/01 - R.I.P_.mp3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/beets/util/__init__.py", line 503, in move
    shutil.copyfile(path, tmp)
  File "/usr/lib/python3.11/shutil.py", line 256, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: b'/music/Actress/R.I.P/01 - R.I.P_.mp3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/beets/util/__init__.py", line 508, in move
    raise FilesystemError(exc, 'move', (path, dest),
beets.util.FilesystemError: No such file or directory while moving /music/Actress/R.I.P/01 - R.I.P_.mp3 to /incoming/Actress/R.I.P. [15093]/01 - R.I.P_.mp3

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/lsiopy/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/beets/ui/__init__.py", line 1285, in main
    _raw_main(args)
  File "/lsiopy/lib/python3.11/site-packages/beets/ui/__init__.py", line 1272, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/lsiopy/lib/python3.11/site-packages/beets/ui/commands.py", line 1600, in move_func
    move_items(lib, dest, decargs(args), opts.copy, opts.album, opts.pretend,
  File "/lsiopy/lib/python3.11/site-packages/beets/ui/commands.py", line 1590, in move_items
    obj.move(operation=MoveOperation.MOVE, basedir=dest)
  File "/lsiopy/lib/python3.11/site-packages/beets/library.py", line 922, in move
    self.move_file(dest, operation)
  File "/lsiopy/lib/python3.11/site-packages/beets/library.py", line 821, in move_file
    util.move(self.path, dest)
  File "/lsiopy/lib/python3.11/site-packages/beets/util/__init__.py", line 512, in move
    os.remove(tmp)
FileNotFoundError: [Errno 2] No such file or directory: '/incoming/Actress/R.I.P. [15093]/.01 - R.I.P_.mp325blyavg.beets'

Here's a link to the music files that trigger the bug (if relevant):

Setup

My configuration (output of beet config) is:

#plugins: fetchart embedart convert scrub replaygain lastgenre chroma web
#plugins: convert replaygain lastgenre web duplicates
directory: /music
library: /config/musiclibrary.blb
art_filename: albumart
threaded: yes
original_date: yes
per_disc_numbering: no

#drop2beets:
#    dropbox_path: /incoming

convert:
    auto: no
    ffmpeg: /usr/bin/ffmpeg
    opts: -ab 320k -ac 2 -ar 48000
    max_bitrate: 320
    threads: 1

paths:
    default: $albumartist/$album%aunique{}/$track - $title
    singleton: Non-Album/$artist - $title
    comp: Compilations/$album%aunique{}/$track - $title
    albumtype_soundtrack: Soundtracks/$album/$track $title

import:
    write: yes
    copy: yes
    move: no
    resume: yes
    incremental: yes
    quiet: yes
    quiet_fallback: asis
    timid: no
    log: /config/beet.log
    autotag: yes

lastgenre:
    auto: yes
    source: album

embedart:
    auto: yes

fetchart:
    auto: yes

replaygain:
    auto: yes

scrub:
    auto: yes

replace:
    '^\.': _
    '[\x00-\x1f]': _
    '[<>:"\?\*\|]': _
    '[\xE8-\xEB]': e
    '[\xEC-\xEF]': i
    '[\xE2-\xE6]': a
    '[\xF2-\xF6]': o
    '[\xF8]': o
    '\.$': _
    '\s+$': ''

web:
    host: 0.0.0.0
    port: 8337
taylorthurlow commented 8 months ago

These error traces can be a little misleading if you don't read super closely. Your error above is actually more than one error, where one causes the next, which causes the next:

During handling of the above exception, another exception occurred:

The first error that occurs is this one:

Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/beets/util/__init__.py", line 496, in move
    os.replace(path, dest)
OSError: [Errno 18] Cross-device link: b'/music/Actress/R.I.P/01 - R.I.P_.mp3' -> b'/incoming/Actress/R.I.P. [15093]/01 - R.I.P_.mp3'

Python is unhappy about /music and /incoming being on separate "devices". What a device means depends on your setup. Are you running Ubuntu on WSL or just plain Ubuntu?