diff --git a/beets/importer/tasks.py b/beets/importer/tasks.py index 646b64e7f..1c1d0e61e 100644 --- a/beets/importer/tasks.py +++ b/beets/importer/tasks.py @@ -680,6 +680,8 @@ class SingletonImportTask(ImportTask): return [self.item] def apply_metadata(self): + if config["import"]["from_scratch"]: + self.item.clear() autotag.apply_item_metadata(self.item, self.match.info) def _emit_imported(self, lib): diff --git a/docs/changelog.rst b/docs/changelog.rst index 2ba9f5cbd..84bb0cc02 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -90,6 +90,8 @@ Bug fixes: - :doc:`/plugins/ftintitle`: Fixed artist name splitting to prioritize explicit featuring tokens (feat, ft, featuring) over generic separators (&, and), preventing incorrect splits when both are present. +- :doc:`reference/cli`: Fix 'from_scratch' option for singleton imports: delete + all (old) metadata when new metadata is applied. :bug:`3706` For plugin developers: diff --git a/test/test_importer.py b/test/test_importer.py index c1768df3e..6ae7d562b 100644 --- a/test/test_importer.py +++ b/test/test_importer.py @@ -258,6 +258,17 @@ class ImportSingletonTest(AutotagImportTestCase): assert self.lib.items().get().title == "Applied Track 1" assert (self.lib_path / "singletons" / "Applied Track 1.mp3").exists() + def test_apply_from_scratch_removes_other_metadata(self): + config["import"]["from_scratch"] = True + + for mediafile in self.import_media: + mediafile.comments = "Tag Comment" + mediafile.save() + + self.importer.add_choice(importer.Action.APPLY) + self.importer.run() + assert self.lib.items().get().comments == "" + def test_skip_does_not_add_track(self): self.importer.add_choice(importer.Action.SKIP) self.importer.run()