mirror of
https://github.com/beetbox/beets.git
synced 2025-12-07 09:04:33 +01:00
Merge pull request #4900 from fracai/4326-scrub-no-rewrite
4326 scrub should not restore on import if "write" is disabled
This commit is contained in:
commit
c15ccb16bf
3 changed files with 60 additions and 2 deletions
|
|
@ -109,7 +109,7 @@ class ScrubPlugin(BeetsPlugin):
|
||||||
self._log.error('could not scrub {0}: {1}',
|
self._log.error('could not scrub {0}: {1}',
|
||||||
util.displayable_path(path), exc)
|
util.displayable_path(path), exc)
|
||||||
|
|
||||||
def _scrub_item(self, item, restore=True):
|
def _scrub_item(self, item, restore):
|
||||||
"""Remove tags from an Item's associated file and, if `restore`
|
"""Remove tags from an Item's associated file and, if `restore`
|
||||||
is enabled, write the database's tags back to the file.
|
is enabled, write the database's tags back to the file.
|
||||||
"""
|
"""
|
||||||
|
|
@ -146,4 +146,4 @@ class ScrubPlugin(BeetsPlugin):
|
||||||
for item in task.imported_items():
|
for item in task.imported_items():
|
||||||
self._log.debug('auto-scrubbing {0}',
|
self._log.debug('auto-scrubbing {0}',
|
||||||
util.displayable_path(item.path))
|
util.displayable_path(item.path))
|
||||||
self._scrub_item(item)
|
self._scrub_item(item, ui.should_write())
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,10 @@ New features:
|
||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
||||||
|
* :doc:`/plugins/scrub`: Fixed the import behavior where scrubbed database tags
|
||||||
|
were restored to newly imported tracks with config settings ``scrub.auto: yes``
|
||||||
|
and ``import.write: no``.
|
||||||
|
:bug:`4326`
|
||||||
* :doc:`/plugins/deezer`: Fixed the error where Deezer plugin would crash if non-Deezer id is passed during import.
|
* :doc:`/plugins/deezer`: Fixed the error where Deezer plugin would crash if non-Deezer id is passed during import.
|
||||||
* :doc:`/plugins/fetchart`: Fix fetching from Cover Art Archive when the
|
* :doc:`/plugins/fetchart`: Fix fetching from Cover Art Archive when the
|
||||||
`maxwidth` option is set to one of the supported Cover Art Archive widths.
|
`maxwidth` option is set to one of the supported Cover Art Archive widths.
|
||||||
|
|
|
||||||
|
|
@ -244,6 +244,60 @@ class ImportHelper(TestHelper):
|
||||||
self.assertEqual(len(os.listdir(syspath(self.libdir))), 0)
|
self.assertEqual(len(os.listdir(syspath(self.libdir))), 0)
|
||||||
|
|
||||||
|
|
||||||
|
class ScrubbedImportTest(_common.TestCase, ImportHelper):
|
||||||
|
def setUp(self):
|
||||||
|
self.setup_beets(disk=True)
|
||||||
|
self.load_plugins('scrub')
|
||||||
|
self._create_import_dir(2)
|
||||||
|
self._setup_import_session(autotag=False)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.unload_plugins()
|
||||||
|
self.teardown_beets()
|
||||||
|
|
||||||
|
def test_tags_not_scrubbed(self):
|
||||||
|
config['plugins'] = ['scrub']
|
||||||
|
config['scrub']['auto'] = False
|
||||||
|
config['import']['write'] = True
|
||||||
|
for mediafile in self.import_media:
|
||||||
|
self.assertEqual(mediafile.artist, 'Tag Artist')
|
||||||
|
self.assertEqual(mediafile.album, 'Tag Album')
|
||||||
|
self.importer.run()
|
||||||
|
for item in self.lib.items():
|
||||||
|
imported_file = os.path.join(item.path)
|
||||||
|
imported_file = MediaFile(imported_file)
|
||||||
|
self.assertEqual(imported_file.artist, 'Tag Artist')
|
||||||
|
self.assertEqual(imported_file.album, 'Tag Album')
|
||||||
|
|
||||||
|
def test_tags_restored(self):
|
||||||
|
config['plugins'] = ['scrub']
|
||||||
|
config['scrub']['auto'] = True
|
||||||
|
config['import']['write'] = True
|
||||||
|
for mediafile in self.import_media:
|
||||||
|
self.assertEqual(mediafile.artist, 'Tag Artist')
|
||||||
|
self.assertEqual(mediafile.album, 'Tag Album')
|
||||||
|
self.importer.run()
|
||||||
|
for item in self.lib.items():
|
||||||
|
imported_file = os.path.join(item.path)
|
||||||
|
imported_file = MediaFile(imported_file)
|
||||||
|
self.assertEqual(imported_file.artist, 'Tag Artist')
|
||||||
|
self.assertEqual(imported_file.album, 'Tag Album')
|
||||||
|
|
||||||
|
def test_tags_not_restored(self):
|
||||||
|
config['plugins'] = ['scrub']
|
||||||
|
config['scrub']['auto'] = True
|
||||||
|
config['import']['write'] = False
|
||||||
|
for mediafile in self.import_media:
|
||||||
|
self.assertEqual(mediafile.artist, 'Tag Artist')
|
||||||
|
self.assertEqual(mediafile.album, 'Tag Album')
|
||||||
|
self.importer.run()
|
||||||
|
for item in self.lib.items():
|
||||||
|
imported_file = os.path.join(item.path)
|
||||||
|
imported_file = MediaFile(imported_file)
|
||||||
|
self.assertEqual(imported_file.artist, None)
|
||||||
|
self.assertEqual(imported_file.album, None)
|
||||||
|
|
||||||
|
|
||||||
@_common.slow_test()
|
@_common.slow_test()
|
||||||
class NonAutotaggedImportTest(_common.TestCase, ImportHelper):
|
class NonAutotaggedImportTest(_common.TestCase, ImportHelper):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue