Merge pull request #1681 from sampsyo/314-reimport-art

Fix #314: Delete old album art during re-import
This commit is contained in:
reiv 2015-11-04 18:46:45 +01:00
commit a7952b1b1d
4 changed files with 23 additions and 0 deletions

View file

@ -718,6 +718,7 @@ class ImportTask(BaseImportTask):
if replaced_album:
self.album.added = replaced_album.added
self.album.update(replaced_album._values_flex)
self.album.artpath = replaced_album.artpath
self.album.store()
log.debug(
u'Reimported album: added {0}, flexible '

View file

@ -434,6 +434,9 @@ class FetchArtPlugin(plugins.BeetsPlugin, RequestMixin):
def fetch_art(self, session, task):
"""Find art for the album being imported."""
if task.is_album: # Only fetch art for full albums.
if task.album.artpath and os.path.isfile(task.album.artpath):
# Album already has art (probably a re-import); skip it.
return
if task.choice_flag == importer.action.ASIS:
# For as-is imports, don't search Web sources for art.
local = True

View file

@ -16,6 +16,10 @@ Fixes:
when there were not. :bug:`1652`
* :doc:`plugins/lastgenre`: Clean up the reggae related genres somewhat.
Thanks to :user:`Freso`. :bug:`1661`
* The importer now correctly moves album art files when re-importing.
:bug:`314`
* :doc:`/plugins/fetchart`: In auto mode, skips albums that already have
art attached to them so as not to interfere with re-imports. :bug:`314`
* :doc:`plugins/fetchart`: The plugin now only resizes album art if necessary,
rather than always by default. :bug:`1264`
* :doc:`plugins/fetchart`: Fix a bug where a database reference to a

View file

@ -1592,6 +1592,21 @@ class ReimportTest(unittest.TestCase, ImportHelper):
self.importer.run()
self.assertEqual(self._item().added, 4747.0)
def test_reimported_item_preserves_art(self):
self._setup_session()
art_source = os.path.join(_common.RSRC, 'abbey.jpg')
replaced_album = self._album()
replaced_album.set_art(art_source)
replaced_album.store()
old_artpath = replaced_album.artpath
self.importer.run()
new_album = self._album()
new_artpath = new_album.art_destination(art_source)
self.assertEqual(new_album.artpath, new_artpath)
self.assertTrue(os.path.exists(new_artpath))
if new_artpath != old_artpath:
self.assertFalse(os.path.exists(old_artpath))
class ImportPretendTest(_common.TestCase, ImportHelper):
""" Test the pretend commandline option