From ba8fcdfd47d98b78e666bc44be836bc77f4ec431 Mon Sep 17 00:00:00 2001 From: Zsin Skri Date: Sun, 1 Jul 2018 20:23:13 +0200 Subject: [PATCH 1/3] from_scratch import: only remove writable fields When importing with the configuration option ``from_scratch`` set, only remove writable fields from library. E.g. keep fields like ``format`` and ``bitrate``. This fixes #2972. --- beets/library.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beets/library.py b/beets/library.py index 4ab15a599..919d4cf7c 100644 --- a/beets/library.py +++ b/beets/library.py @@ -564,7 +564,7 @@ class Item(LibModel): def clear(self): """Set all key/value pairs to None.""" - for key in self._media_fields: + for key in self._media_tag_fields: setattr(self, key, None) def get_album(self): From 77242d6b2b83a2f413ec5186b97f17a1313079bc Mon Sep 17 00:00:00 2001 From: Zsin Skri Date: Sun, 1 Jul 2018 20:23:41 +0200 Subject: [PATCH 2/3] add test: from_scratch only removes writeable Tests for commit ba8fcdfd from_scratch import: only remove writable fields. --- test/test_importer.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/test_importer.py b/test/test_importer.py index 6721f0dc2..8d6ba425a 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -644,6 +644,21 @@ class ImportTest(_common.TestCase, ImportHelper): self.importer.run() self.assertEqual(self.lib.items().get().genre, u'') + def test_apply_from_scratch_keeps_format(self): + config['import']['from_scratch'] = True + + self.importer.add_choice(importer.action.APPLY) + self.importer.run() + self.assertEqual(self.lib.items().get().format, u'MP3') + + def test_apply_from_scratch_keeps_bitrate(self): + config['import']['from_scratch'] = True + bitrate = 80000 + + self.importer.add_choice(importer.action.APPLY) + self.importer.run() + self.assertEqual(self.lib.items().get().bitrate, bitrate) + def test_apply_with_move_deletes_import(self): config['import']['move'] = True From dd327055bdd932fc7a0feb0de7b4a58969c03030 Mon Sep 17 00:00:00 2001 From: Zsin Skri Date: Sun, 1 Jul 2018 20:42:22 +0200 Subject: [PATCH 3/3] update changelog Add changelog entry for commit ba8fcdfd from_scratch import: only remove writable fields. --- docs/changelog.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index bb21f21be..b6e395d4e 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -26,6 +26,9 @@ Fixes: * Display the artist credit when matching albums if the ref:`artist_credit` configuration option is set. :bug:`2953` +* With the :ref:`from_scratch` configuration option set, only writable fields + are cleared. Beets now no longer ignores the format your music is saved in. + :bug:`2972` 1.4.7 (May 29, 2018)