Skip to content

fetchart: handle FilesystemError when setting album art#6516

Open
lawrence3699 wants to merge 1 commit intobeetbox:masterfrom
lawrence3699:fix/fetchart-filesystem-error
Open

fetchart: handle FilesystemError when setting album art#6516
lawrence3699 wants to merge 1 commit intobeetbox:masterfrom
lawrence3699:fix/fetchart-filesystem-error

Conversation

@lawrence3699
Copy link
Copy Markdown

Description

Fixes #6193.

Problem

When fetchart encounters a FilesystemError during set_art (e.g. a file locked by another process on Windows, or a cross-device move permission error), the unhandled exception crashes the import session or the fetchart CLI command.

The cleanup method at line ~520 already catches FilesystemError and logs it gracefully, but the two _set_art call sites don't.

Fix

Wrap both _set_art call sites in try/except util.FilesystemError:

  • assign_art() (import pipeline): log the error and return early, skipping the prune step since no art was set.
  • batch_fetch_art() (CLI command): log the error and show "error setting art" in the output instead of crashing.

Tests

Added two tests covering both error paths:

  • test_batch_fetch_filesystem_error — verifies the CLI command reports the error message instead of crashing.
  • test_assign_art_filesystem_error — verifies the import path returns gracefully on error.

All existing fetchart tests pass.

To Do

  • Changelog
  • Tests
  • Documentation

When set_art encounters a permissions error or cross-device move failure
(e.g. file locked by foobar2000 on Windows), the unhandled
FilesystemError crashes the import or the fetchart CLI command.

Wrap both _set_art call sites in try/except FilesystemError, matching
the pattern already used in the cleanup method (line ~520). On failure,
log a warning and continue instead of aborting.

Fixes beetbox#6193.
Copilot AI review requested due to automatic review settings April 10, 2026 01:51
@lawrence3699 lawrence3699 requested a review from a team as a code owner April 10, 2026 01:51
@github-actions github-actions Bot added the fetchart fetchart plugin label Apr 10, 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

PR make fetchart not crash when filesystem say “no” during set_art (Windows lock, cross-device move, etc). PR fit in beetsplug fetchart reliability: keep import + CLI running, just warn and move on.

Changes:

  • Catch util.FilesystemError around _set_art in import hook (assign_art) and CLI path (batch_fetch_art).
  • On CLI error, print “error setting art” instead of throwing.
  • Add tests for both error paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
beetsplug/fetchart.py Wrap _set_art calls with try/except util.FilesystemError and log + continue/return.
test/plugins/test_fetchart.py Add regression tests for FilesystemError in CLI and import assign path.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.42%. Comparing base (fd586ef) to head (b03b5c3).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6516      +/-   ##
==========================================
+ Coverage   70.40%   70.42%   +0.02%     
==========================================
  Files         148      148              
  Lines       18806    18814       +8     
  Branches     3067     3067              
==========================================
+ Hits        13240    13250      +10     
+ Misses       4916     4913       -3     
- Partials      650      651       +1     
Files with missing lines Coverage Δ
beetsplug/fetchart.py 74.52% <100.00%> (+0.28%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@snejus snejus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just fix the formatting issues and add a note to the changelog please.

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

3 participants