Exception when copying files
I saw this exception at the end of a beet import job, and none of the expected artifacts got copied:
Traceback (most recent call last):
File "/home/sam/.local/bin/beet", line 11, in <module>
load_entry_point('beets==1.4.7', 'console_scripts', 'beet')()
File "/home/sam/.local/lib/python3.6/site-packages/beets/ui/__init__.py", line 1256, in main
_raw_main(args)
File "/home/sam/.local/lib/python3.6/site-packages/beets/ui/__init__.py", line 1245, in _raw_main
plugins.send('cli_exit', lib=lib)
File "/home/sam/.local/lib/python3.6/site-packages/beets/plugins.py", line 476, in send
result = handler(**arguments)
File "/home/sam/.local/lib/python3.6/site-packages/beets/plugins.py", line 140, in wrapper
return func(*args, **kwargs)
File "/home/sam/.local/lib/python3.6/site-packages/beetsplug/copyartifacts.py", line 127, in process_events
self.process_artifacts(item['files'], item['mapping'], False)
File "/home/sam/.local/lib/python3.6/site-packages/beetsplug/copyartifacts.py", line 161, in process_artifacts
dest_file = beets.util.unique_path(dest_file)
File "/home/sam/.local/lib/python3.6/site-packages/beets/util/__init__.py", line 548, in unique_path
match = re.search(br'\.(\d)+$', base)
File "/usr/lib64/python3.6/re.py", line 182, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a bytes pattern on a string-like object
I should note that I am running with https://github.com/sbarakat/beets-copyartifacts/pull/43 checked out. I would otherwise have seen the exception from issue #38
I added some tracing and discovered that dest_file has type str(). This seems wrong, as source_file has type bytes().
Looking at beets.util.unique_path(), it runs a regexp with a bytes() on the input but only in the situation that the destination path already exists. So it looks like there is a bug here, but it only triggers a crash if the 'copyartifacts' plugin tries to copy a file into a directory that already contains a file with the same name.