diff --git a/beetsplug/zero.py b/beetsplug/zero.py index ab1bfa5ca..4623a0c2d 100644 --- a/beetsplug/zero.py +++ b/beetsplug/zero.py @@ -124,11 +124,15 @@ class ZeroPlugin(BeetsPlugin): """ fields_set = False - if "disc" in tags and self.config["omit_single_disc"].get(bool): - if item.disctotal == 1: + if self.config["omit_single_disc"].get(bool) and item.disctotal == 1: + if "disc" in tags: fields_set = True self._log.debug("disc: {.disc} -> None", item) tags["disc"] = None + if "disctotal" in tags: + fields_set = True + self._log.debug("disctotal: {.disctotal} -> None", item) + tags["disctotal"] = None if not self.fields_to_progs: self._log.warning("no fields list to remove") diff --git a/test/plugins/test_zero.py b/test/plugins/test_zero.py index b08bf0dca..f466a409e 100644 --- a/test/plugins/test_zero.py +++ b/test/plugins/test_zero.py @@ -261,7 +261,8 @@ class ZeroPluginTest(PluginTestCase): mf = MediaFile(syspath(item.path)) assert mf.comments is None - assert mf.disc == 0 + assert mf.disc is None + assert mf.disctotal is None def test_omit_single_disc_with_tags_multi(self): item = self.add_item_fixture( @@ -276,6 +277,7 @@ class ZeroPluginTest(PluginTestCase): mf = MediaFile(syspath(item.path)) assert mf.comments is None assert mf.disc == 1 + assert mf.disctotal == 4 def test_omit_single_disc_only_change_single(self): item = self.add_item_fixture(disctotal=1, disc=1) @@ -285,7 +287,8 @@ class ZeroPluginTest(PluginTestCase): item.write() mf = MediaFile(syspath(item.path)) - assert mf.disc == 0 + assert mf.disc is None + assert mf.disctotal is None def test_omit_single_disc_only_change_multi(self): item = self.add_item_fixture(disctotal=4, disc=1) @@ -296,6 +299,7 @@ class ZeroPluginTest(PluginTestCase): mf = MediaFile(syspath(item.path)) assert mf.disc == 1 + assert mf.disctotal == 4 def test_empty_query_n_response_no_changes(self): item = self.add_item_fixture(