beetbox / beetbox/beets

Beet move unable to find files, creating incorrect album names

Open
#5,079 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
15.7k
Forks
2.1k
Avg merge
4d 21h
Merged PRs (30d)
31

Description

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:

```sh
$ 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
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

* OS: Ubuntu
* Python version: 3.11.6
* beets version: 1.6.0
* Turning off plugins made problem go away (yes/no): no

My configuration (output of `beet config`) is:

```yaml
#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
```

Contributor guide

Open the contributing guide

Research direction

Start with beets/util/__init__.py, especially move, then follow library.py move_file and the move_items entry point in ui/commands.py. Reproduce with the reported beet -vv move -d /incoming command and configuration; done means the cross-device move completes without incorrect album paths or follow-up file-not-found errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.