File not found exception aborts import - occurs during "remove old"
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 31
Description
### Problem
I'm running beet on multiple folders where at least one album is duplicate (8/8 tracks and 7/8 tracks). I want to clean them up so that I only have one entry. Problem is that once beet detected that it already is in the library, I press "R" for remove old files.
Shortly after that, this error occurs and beet aborts the whole import process:
```
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.9/site-packages/beets/util/__init__.py", line 522, in move
os.replace(syspath(path), syspath(dest))
FileNotFoundError: [Errno 2] No such file or directory: b'/media/audio/Apocalyptica/Plays Metallica by Four Cellos [1926]/01 Enter Sandman.mp3' -> b'/media/audio/Apocalyptica/Plays Metallica by Four Cellos/01 Enter Sandman.mp3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/.local/bin/beet", line 8, in
sys.exit(main())
File "/home/pi/.local/lib/python3.9/site-packages/beets/ui/__init__.py", line 1865, in main
_raw_main(args)
File "/home/pi/.local/lib/python3.9/site-packages/beets/ui/__init__.py", line 1852, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/home/pi/.local/lib/python3.9/site-packages/beets/ui/commands.py", line 1395, in import_func
import_files(lib, paths, query)
File "/home/pi/.local/lib/python3.9/site-packages/beets/ui/commands.py", line 1326, in import_files
session.run()
File "/home/pi/.local/lib/python3.9/site-packages/beets/importer.py", line 360, in run
pl.run_parallel(QUEUE_SIZE)
File "/home/pi/.local/lib/python3.9/site-packages/beets/util/pipeline.py", line 447, in run_parallel
raise exc_info[1].with_traceback(exc_info[2])
File "/home/pi/.local/lib/python3.9/site-packages/beets/util/pipeline.py", line 359, in run
self.coro.send(msg)
File "/home/pi/.local/lib/python3.9/site-packages/beets/util/pipeline.py", line 171, in coro
task = func(*(args + (task,)))
File "/home/pi/.local/lib/python3.9/site-packages/beets/importer.py", line 1692, in manipulate_files
task.manipulate_files(
File "/home/pi/.local/lib/python3.9/site-packages/beets/importer.py", line 801, in manipulate_files
item.move(operation)
File "/home/pi/.local/lib/python3.9/site-packages/beets/library.py", line 1025, in move
self.move_file(dest, operation)
File "/home/pi/.local/lib/python3.9/site-packages/beets/library.py", line 909, in move_file
util.move(self.path, dest)
File "/home/pi/.local/lib/python3.9/site-packages/beets/util/__init__.py", line 534, in move
with open(syspath(path), "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: b'/media/audio/Apocalyptica/Plays Metallica by Four Cellos [1926]/01 Enter Sandman.mp3'
```
My problem is, that this behavior is repeatable and beet also wants to continue with the same album again.
Once I merge the files, it works.
### Setup
* OS: Raspberry Pi OS
* Python version: 3.9.2
* beets version: 2.0.0
* Turning off plugins made problem go away (yes/no): no
My configuration (output of `beet config`) is:
```yaml
threaded: yes
terminal_encoding: utf-8
directory: /media/audio
library: ~/.beets/musiclibrary.db
match:
preferred:
countries: ['DE', 'XE', 'XW', 'US', 'GB|UK']
media: ['CD', 'Digital Media|File']
original_year: yes
duplicate_action: merge
duplicate_verbose_prompt: yes
import:
copy: no
write: yes
move: yes
incremental: yes
log: ~/.beets/import.log
plugins: inline convert web chroma replaygain duplicates fromfilename
replaygain:
backend: command
auto: no
web:
host: 0.0.0.0
acoustid:
apikey: XXXXXXX
fetchart:
auto: yes
cautious: yes
musicbrainz:
genres: yes
external_ids:
discogs: yes
spotify: yes
bandcamp: yes
```
Contributor guide
Research direction
Reproduce the duplicate import and choose “R” for remove old, then trace the failure through beets/util/__init__.py:move, beets/library.py:move_file, and beets/importer.py:manipulate_files as shown in the traceback. Compare the behavior with the merge path; done means a missing source file no longer aborts the entire import or repeatedly presents the same album.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100