mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 04:55:10 +01:00
Clearart: Do not update files without an embedded image
This commit is contained in:
parent
29b9958626
commit
dd824e69b2
3 changed files with 19 additions and 2 deletions
|
|
@ -210,5 +210,8 @@ def clear(log, lib, query):
|
|||
items = lib.items(query)
|
||||
log.info("Clearing album art from {} items", len(items))
|
||||
for item in items:
|
||||
log.debug("Clearing art for {}", item)
|
||||
item.try_write(tags={"images": None})
|
||||
if mediafile.MediaFile(syspath(item.path)).images:
|
||||
log.debug("Clearing art for {}", item)
|
||||
item.try_write(tags={"images": None})
|
||||
else:
|
||||
log.debug("No art to clean for {}", item)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
import os.path
|
||||
import tempfile
|
||||
from mimetypes import guess_extension
|
||||
from unittest import mock
|
||||
|
||||
import requests
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import os
|
|||
import os.path
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
|
@ -225,10 +226,22 @@ class EmbedartCliTest(IOMixin, PluginMixin, FetchImageHelper, BeetsTestCase):
|
|||
item = album.items()[0]
|
||||
self.io.addinput("y")
|
||||
self.run_command("embedart", "-f", self.small_artpath)
|
||||
embedded_time = item.current_mtime()
|
||||
time.sleep(1)
|
||||
|
||||
self.io.addinput("y")
|
||||
self.run_command("clearart")
|
||||
mediafile = MediaFile(syspath(item.path))
|
||||
assert not mediafile.images
|
||||
clear_time = item.current_mtime()
|
||||
assert clear_time > embedded_time
|
||||
time.sleep(1)
|
||||
|
||||
# A run on a file without an image should not be modified
|
||||
self.io.addinput("y")
|
||||
self.run_command("clearart")
|
||||
no_clear_time = item.current_mtime()
|
||||
assert no_clear_time == clear_time
|
||||
|
||||
def test_clear_art_with_no_input(self):
|
||||
self._setup_data()
|
||||
|
|
|
|||
Loading…
Reference in a new issue