mirror of
https://github.com/beetbox/beets.git
synced 2026-02-08 08:25:23 +01:00
Merge 8f56d33ca4 into cdfb813910
This commit is contained in:
commit
bb8aa17573
3 changed files with 23 additions and 1 deletions
|
|
@ -1445,6 +1445,16 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin):
|
|||
"move"
|
||||
].get(bool)
|
||||
|
||||
def _is_candidate_fallback(self, candidate: Candidate) -> bool:
|
||||
try:
|
||||
return (
|
||||
candidate.path is not None
|
||||
and self.fallback is not None
|
||||
and os.path.samefile(candidate.path, self.fallback)
|
||||
)
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
# Asynchronous; after music is added to the library.
|
||||
def fetch_art(self, session: ImportSession, task: ImportTask) -> None:
|
||||
"""Find art for the album being imported."""
|
||||
|
|
@ -1493,7 +1503,7 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin):
|
|||
|
||||
self._set_art(task.album, candidate, not removal_enabled)
|
||||
|
||||
if removal_enabled:
|
||||
if removal_enabled and not self._is_candidate_fallback(candidate):
|
||||
task.prune(candidate.path)
|
||||
|
||||
# Manual album art fetching.
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ New features:
|
|||
|
||||
Bug fixes:
|
||||
|
||||
- :doc:`plugins/fetchart`: Prevent deletion of configured fallback cover art
|
||||
|
||||
For packagers:
|
||||
|
||||
Other changes:
|
||||
|
|
|
|||
|
|
@ -310,6 +310,16 @@ class FSArtTest(UseThePlugin):
|
|||
]
|
||||
assert candidates == paths
|
||||
|
||||
@patch("os.path.samefile")
|
||||
def test_is_candidate_fallback_os_error(self, mock_samefile):
|
||||
mock_samefile.side_effect = OSError("os error")
|
||||
fallback = os.path.join(self.temp_dir, b"a.jpg")
|
||||
self.plugin.fallback = fallback
|
||||
candidate = fetchart.Candidate(logger, self.source.ID, fallback)
|
||||
result = self.plugin._is_candidate_fallback(candidate)
|
||||
mock_samefile.assert_called_once()
|
||||
assert not result
|
||||
|
||||
|
||||
class CombinedTest(FetchImageTestCase, CAAHelper):
|
||||
ASIN = "xxxx"
|
||||
|
|
|
|||
Loading…
Reference in a new issue