fetchart: catch FilesystemError in _set_art instead of crashing#6660
Open
jesustorres-code wants to merge 1 commit into
Open
fetchart: catch FilesystemError in _set_art instead of crashing#6660jesustorres-code wants to merge 1 commit into
jesustorres-code wants to merge 1 commit into
Conversation
When saving artwork fails due to a permissions error or cross-device move (e.g. the destination file is locked by another process on Windows), the uncaught FilesystemError crashes the entire import pipeline. Catch FilesystemError in _set_art() and log a warning instead so the import continues gracefully for the rest of the library. Fixes beetbox#6193
|
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. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6660 +/- ##
==========================================
- Coverage 72.46% 72.45% -0.01%
==========================================
Files 161 161
Lines 20710 20714 +4
Branches 3276 3276
==========================================
+ Hits 15007 15008 +1
- Misses 4977 4980 +3
Partials 726 726
🚀 New features to boost your workflow:
|
Contributor
|
The import will also error out and not finished if the file is locked and can't be moved, or am I missing something? The same error would also be raised for all metadata beets wants to write to the files in the last step during the import. This proposed fix will just postpone the error and it will be raised a few seconds later again, right? |
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.
Fixes #6193
Problem
When
fetcharttries to save artwork and the destination file is locked by another process (e.g. foobar2000 on Windows), aFilesystemErrorpropagates uncaught from_set_art→album.set_art()→util.move(), crashing the entire import pipeline with an unhelpful traceback.Fix
Wrap
album.set_art()in atry/except util.FilesystemErrorblock in_set_art(). On failure, log awarningwith the album name and error message, then return early so the rest of the import continues.This also covers the manual
beet fetchartcommand path, which goes through the same_set_art()method.Behaviour change
Before: import crashes with an unhandled exception.
After: a warning is logged ("fetchart: could not save artwork for ...") and the import continues.