Holzhaus / beets-extrafiles

A plugin for beets that copies additional files and directories during the import process.
MIT License
46 stars 10 forks source link

Starts moving data from root with album merge #20

Open austinbutler opened 4 years ago

austinbutler commented 4 years ago

I was importing a double CD that was in two folders. Disc 1 imported without issue and the extra files in the folder were moved properly. When I went to do disk 2, beets saw it was the same album and asked if I wanted to skip, merge, etc. I chose merge.

This album is already in the library!
Old: 20 items, FLAC, 889kbps, 63:11, 400.4 MiB
New: 20 items, FLAC, 884kbps, 68:20, 433.8 MiB
[S]kip new, Keep both, Remove old, Merge all? M

Beets moved the music files just fine but I got a traceback when it got to non-music files. I found that the non-music files had not been moved from their original location, and (more critically) I found extrafiles had apparently decided to move everything in the mount point to where the album was located. Luckily it didn't get too far before trying to move one of the base folders into the album's folder, which brought about the error below. This plugin has worked great in all other cases, so my guess is something with the merge operation throws it off.

Traceback (most recent call last):
  File "/home/austin/.pyenv/versions/3.8.3/lib/python3.8/shutil.py", line 788, in move
    os.rename(src, real_dst)
OSError: [Errno 22] Invalid argument: '/mnt/data/Media' -> '/mnt/data/Media/Music/The Slits/2009 - Cut/Media'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/austin/.pyenv/versions/3.8.3/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.9', 'console_scripts', 'beet')()
  File "/home/austin/.pyenv/versions/3.8.3/lib/python3.8/site-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/home/austin/.pyenv/versions/3.8.3/lib/python3.8/site-packages/beets/ui/__init__.py", line 1255, in _raw_main
    plugins.send('cli_exit', lib=lib)
  File "/home/austin/.pyenv/versions/3.8.3/lib/python3.8/site-packages/beets/plugins.py", line 489, in send
    result = handler(**arguments)
  File "/home/austin/.pyenv/versions/3.8.3/lib/python3.8/site-packages/beets/plugins.py", line 143, in wrapper
    return func(*args, **kwargs)
  File "/home/austin/.pyenv/versions/3.8.3/lib/python3.8/site-packages/beetsplug/extrafiles.py", line 102, in on_cli_exit
    self.process_items(files, action=self._move_file)
  File "/home/austin/.pyenv/versions/3.8.3/lib/python3.8/site-packages/beetsplug/extrafiles.py", line 153, in process_items
    action(sourcepath, destpath)
  File "/home/austin/.pyenv/versions/3.8.3/lib/python3.8/site-packages/beetsplug/extrafiles.py", line 131, in _move_file
    shutil.move(sourcepath, destpath)
  File "/home/austin/.pyenv/versions/3.8.3/lib/python3.8/shutil.py", line 796, in move
    raise Error("Cannot move a directory '%s' into itself"
shutil.Error: Cannot move a directory '/mnt/data/Media' into itself '/mnt/data/Media/Music/The Slits/2009 - Cut/Media'.

My config:

extrafiles:
    patterns:
        all: '*.*'
ssssam commented 4 years ago

I experienced the same thing, again during an album merge. In this case the plugin started copying everything from my home directory.

critbase commented 3 years ago

I've run into this same issue as well. Is it possible the '*.*' pattern is causing issues somehow?

austinbutler commented 3 years ago

@ssssam @critbase were you both also using the same pattern I was?

ssssam commented 3 years ago
extrafiles:
  patterns:
    all: '*.*'

Looks like I was!

scztt commented 3 years ago

I am seeing this as well - all files in my import root that were NOT imported ended up being moved to one of my merged album folders. I believe it was the FIRST album I merged, but I wasn't paying close attention so I can't be sure.