Skip to content

fetchart: catch FilesystemError in _set_art instead of crashing#6660

Open
jesustorres-code wants to merge 1 commit into
beetbox:masterfrom
jesustorres-code:fix/fetchart-graceful-filesystem-error
Open

fetchart: catch FilesystemError in _set_art instead of crashing#6660
jesustorres-code wants to merge 1 commit into
beetbox:masterfrom
jesustorres-code:fix/fetchart-graceful-filesystem-error

Conversation

@jesustorres-code
Copy link
Copy Markdown

Fixes #6193

Problem

When fetchart tries to save artwork and the destination file is locked by another process (e.g. foobar2000 on Windows), a FilesystemError propagates uncaught from _set_artalbum.set_art()util.move(), crashing the entire import pipeline with an unhelpful traceback.

Fix

Wrap album.set_art() in a try/except util.FilesystemError block in _set_art(). On failure, log a warning with the album name and error message, then return early so the rest of the import continues.

This also covers the manual beet fetchart command 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.

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
@jesustorres-code jesustorres-code requested a review from a team as a code owner May 21, 2026 13:51
@github-actions github-actions Bot added the fetchart fetchart plugin label May 21, 2026
@github-actions
Copy link
Copy Markdown

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
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.45%. Comparing base (c9df7a9) to head (35b3d95).

Files with missing lines Patch % Lines
beetsplug/fetchart.py 40.00% 3 Missing ⚠️
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              
Files with missing lines Coverage Δ
beetsplug/fetchart.py 74.00% <40.00%> (-0.27%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@semohr
Copy link
Copy Markdown
Contributor

semohr commented May 21, 2026

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fetchart fetchart plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants