fetchart: gracefully handle permissions errors when setting album art#6381
Open
danielalanbates wants to merge 1 commit intobeetbox:masterfrom
Open
fetchart: gracefully handle permissions errors when setting album art#6381danielalanbates wants to merge 1 commit intobeetbox:masterfrom
danielalanbates wants to merge 1 commit intobeetbox:masterfrom
Conversation
When another process holds a lock on the destination file (e.g., a media player scanning the folder), `util.move()` raises a `PermissionError` during `os.replace()`. The `finally` cleanup block then also fails on `os.remove()`, masking the original error and crashing the entire import. Fix both layers: - `beets/util/__init__.py`: Wrap the temp file cleanup in the `finally` block with try/except so it never masks the original error. - `beetsplug/fetchart.py`: Catch `FilesystemError` in `assign_art()` and log a warning instead of letting it propagate and crash the import. Closes beetbox#6193 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6381 +/- ##
==========================================
- Coverage 68.96% 68.94% -0.03%
==========================================
Files 140 140
Lines 18685 18692 +7
Branches 3056 3056
==========================================
+ Hits 12886 12887 +1
- Misses 5155 5161 +6
Partials 644 644
🚀 New features to boost your workflow:
|
snejus
requested changes
Mar 2, 2026
Comment on lines
+550
to
+553
| try: | ||
| os.remove(tmp_filename) | ||
| except OSError: | ||
| pass |
| - :doc:`plugins/musicbrainz`: Fix fetching very large releases that have more | ||
| than 500 tracks. :bug:`6355` | ||
| - :doc:`plugins/badfiles`: Fix number of found errors in log message | ||
| - :doc:`plugins/fetchart`: Gracefully handle permissions errors when setting |
Member
There was a problem hiding this comment.
We've had a release since this PR was submitted - move the note under the Unreleased section, thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6193. When another process (e.g., foobar2000) holds a lock on the
destination file,
util.move()raises aPermissionErrorduringos.replace(). Thefinallycleanup block then also fails onos.remove(),masking the original error and crashing the entire import pipeline.
Changes
beets/util/__init__.py— Thefinallyblock inmove()now wrapsos.remove(tmp_filename)in atry/except OSErrorso it never masks theoriginal error when the temp file is also locked.
beetsplug/fetchart.py—assign_art()now catchesFilesystemErrorfrom
_set_art()and logs a warning instead of letting it propagate up thecall stack and crash the import. This matches the graceful error handling
pattern already used elsewhere in fetchart (e.g.,
cleanup()at line 514).docs/changelog.rst— Added changelog entry.Test plan
PermissionError[WinError 32] during cross-drive art move)finallycleanup no longer raises when the temp file is lockedThis PR was created with the assistance of Claude Opus 4.6 by Anthropic. Happy to make any adjustments!