diff --git a/beets/importer.py b/beets/importer.py index 95163b6fd..85d6e0824 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -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 ' diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index d53eaf03f..6847d8828 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -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 diff --git a/docs/changelog.rst b/docs/changelog.rst index 7c5b91217..666a76641 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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 diff --git a/test/test_importer.py b/test/test_importer.py index 7b07ea331..675ac7796 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -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