beetbox/beets

fetchart: permissions errors result in a crash, needs graceful fallback

Closed

#6,193 opened on Nov 28, 2025

 (0 comments) (1 reaction) (0 assignees)Python (1,837 forks)batch import
bugfetchartgood first issue

Repository metrics

Stars
 (12,133 stars)
PR merge metrics
 (Avg merge 26d 4h) (51 merged PRs in 30d)

Description

Problem

I think this is caused by my foorbar2000 instance checking the folder, regardless, fetchart should have a more graceful fallback in this situation.

Led to this problem:

Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\beets\util\__init__.py", line 504, in move
    os.replace(syspath(path), syspath(dest))
OSError: [WinError 17] The system cannot move the file to a different disk drive: '\\\\?\\C:\\Users\\Henry\\AppData\\Local\\Temp\\beets\\beetsplug_fetchart\\2svf0w77.jpg' -> '\\\\?\\E:\\Media Library\\Music\\Digital\\e\\Ed Rush & Optical\\Travel the Galaxy (2009, Virus Recordings VRS007DD) [FLAC 16-44]\\cover.jpg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\beets\util\__init__.py", line 537, in move
    os.replace(tmp_filename, syspath(dest))
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '\\\\?\\E:\\Media Library\\Music\\Digital\\e\\Ed Rush & Optical\\Travel the Galaxy (2009, Virus Recordings VRS007DD) [FLAC 16-44]\\.cover.jpg.jtsvsidc.beets' -> '\\\\?\\E:\\Media Library\\Music\\Digital\\e\\Ed Rush & Optical\\Travel the Galaxy (2009, Virus Recordings VRS007DD) [FLAC 16-44]\\cover.jpg'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python312\Lib\site-packages\beets\util\__init__.py", line 541, in move
    raise FilesystemError(
beets.util.FilesystemError: The process cannot access the file because it is being used by another process while moving C:\Users\Henry\AppData\Local\Temp\beets\beetsplug_fetchart\2svf0w77.jpg to E:\Media Library\Music\Digital\e\Ed Rush & Optical\Travel the Galaxy (2009, Virus Recordings VRS007DD) [FLAC 16-44]\cover.jpg

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python312\Scripts\beet.exe\__main__.py", line 7, in <module>
  File "C:\Python312\Lib\site-packages\beets\ui\__init__.py", line 1635, in main
    _raw_main(args)
  File "C:\Python312\Lib\site-packages\beets\ui\__init__.py", line 1614, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "C:\Python312\Lib\site-packages\beets\ui\commands\import_\__init__.py", line 131, in import_func
    import_files(lib, byte_paths, query)
  File "C:\Python312\Lib\site-packages\beets\ui\commands\import_\__init__.py", line 75, in import_files
    session.run()
  File "C:\Python312\Lib\site-packages\beets\importer\session.py", line 236, in run
    pl.run_parallel(QUEUE_SIZE)
  File "C:\Python312\Lib\site-packages\beets\util\pipeline.py", line 471, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "C:\Python312\Lib\site-packages\beets\util\pipeline.py", line 383, in run
    self.coro.send(msg)
  File "C:\Python312\Lib\site-packages\beets\util\pipeline.py", line 195, in coro
    task = func(*(args + (task,)))
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\beets\importer\stages.py", line 299, in manipulate_files
    task.manipulate_files(
  File "C:\Python312\Lib\site-packages\beets\importer\tasks.py", line 490, in manipulate_files
    plugins.send("import_task_files", session=session, task=self)
  File "C:\Python312\Lib\site-packages\beets\plugins.py", line 639, in send
    if (r := handler(**arguments)) is not None
             ^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\beets\plugins.py", line 329, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\site-packages\beetsplug\fetchart.py", line 1480, in assign_art
    self._set_art(task.album, candidate, not removal_enabled)
  File "C:\Python312\Lib\site-packages\beetsplug\fetchart.py", line 1464, in _set_art
    album.set_art(candidate.path, delete)
  File "C:\Python312\Lib\site-packages\beets\library\models.py", line 565, in set_art
    util.move(path, artdest)
  File "C:\Python312\Lib\site-packages\beets\util\__init__.py", line 546, in move
    os.remove(tmp_filename)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '\\\\?\\E:\\Media Library\\Music\\Digital\\e\\Ed Rush & Optical\\Travel the Galaxy (2009, Virus Recordings VRS007DD) [FLAC 16-44]\\.cover.jpg.jtsvsidc.beets'

Contributor guide