fetchart: catch OSError in _set_art for graceful permission error handling#6662
Open
terminalchai wants to merge 2 commits into
Open
fetchart: catch OSError in _set_art for graceful permission error handling#6662terminalchai wants to merge 2 commits into
terminalchai wants to merge 2 commits into
Conversation
|
Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry. |
Author
|
Added a regression test ( est_set_art_oserror_is_handled_gracefully) and a changelog entry per the contribution guide. Please re-review when you get a chance! |
Author
|
Added a regression test (test_set_art_oserror_is_handled_gracefully) and a changelog entry per the contribution guide. Please re-review when you get a chance! |
Member
|
Just resolve the conflict in the changelog please. |
…dling When album art is being moved to the destination folder, a PermissionError (or other OSError) can occur if the file is locked by another process (e.g. a media player scanning the folder). Previously this caused an unhandled traceback crash. Wrap album.set_art() in a try/except OSError block in _set_art, log a warning, and return False so callers can handle the failure gracefully. Fixes beetbox#6193
auto-merge was automatically disabled
May 22, 2026 20:10
Head branch was pushed to by a user without write access
cc89caf to
d686087
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6662 +/- ##
=======================================
Coverage 72.46% 72.47%
=======================================
Files 161 161
Lines 20719 20725 +6
Branches 3280 3281 +1
=======================================
+ Hits 15014 15020 +6
Misses 4979 4979
Partials 726 726
🚀 New features to boost your workflow:
|
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.
Problem
When fetchart moves album art to the destination folder, a
PermissionError(or other
OSError) can crash beets with an unhandled traceback. This happenswhen a file is locked by another process, such as foobar2000 scanning the folder
during import.
Example traceback from #6193:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another processFix
Wrap
album.set_art()in atry/except OSErrorblock inside_set_art.On failure, log a warning and return
Falseinstead of crashing. Thebatch_fetch_artCLI path now checks the return value and reports"error writing album art"instead of a traceback.Changes
beetsplug/fetchart.py:_set_artnow returnsbool; catchesOSErrorwith a warning logtest/plugins/test_fetchart.py: new testtest_set_art_oserror_is_handled_gracefullyverifies graceful handling whenAlbum.set_artraisesPermissionErrordocs/changelog.rst: bug fix entry addedFixes #6193