Fix #1804: edit plugin moves files

This commit is contained in:
Adrian Sampson 2016-01-08 15:22:28 -08:00
parent 963a66a40c
commit 635052e2ff
3 changed files with 12 additions and 8 deletions

View file

@ -323,4 +323,4 @@ class EditPlugin(plugins.BeetsPlugin):
for ob in objs:
if ob._dirty:
self._log.debug('saving changes to {}', ob)
ob.try_sync(ui.should_write(), False)
ob.try_sync(ui.should_write(), ui.should_move())

View file

@ -39,6 +39,8 @@ Fixes:
major version so ``warning_treshold`` will still work. Thanks to
:user:`JesseWeinstein`. :bug:`1802` :bug:`1803`
* :doc:`/plugins/lyrics`: The Genius backend has been re-enabled.
* :doc:`/plugins/edit`: Editing metadata now moves files, when appropriate
(like the :ref:`modify-cmd` command). :bug:`1804`

View file

@ -107,19 +107,21 @@ class EditCommandTest(unittest.TestCase, TestHelper):
self.assertTrue(all(i.title.startswith(title_starts_with)
for i in self.lib.items()))
def assertItemFieldsModified(self, library_items, items, fields=[]):
def assertItemFieldsModified(self, library_items, items, fields=[],
allowed=['path']):
"""Assert that items in the library (`lib_items`) have different values
on the specified `fields` (and *only* on those fields), compared to
`items`.
An empty `fields` list results in asserting that no modifications have
been performed.
been performed. `allowed` is a list of field changes that are ignored
(they may or may not have changed; the assertion doesn't care).
"""
changed_fields = []
for lib_item, item in zip(library_items, items):
changed_fields.append([field for field in lib_item._fields
if lib_item[field] != item[field]])
self.assertTrue(all(diff_fields == fields for diff_fields in
changed_fields))
diff_fields = [field for field in lib_item._fields
if lib_item[field] != item[field]]
self.assertEqual(set(diff_fields).difference(allowed),
set(fields))
def test_title_edit_discard(self):
"""Edit title for all items in the library, then discard changes-"""