Use should_write for modify, update, and mbsync

This should address the surprising situation in #1697, where `import` went
fine but then `update` unexpectedly changed filenames.
This commit is contained in:
Adrian Sampson 2015-11-07 13:34:47 -08:00
parent d78ee1cf28
commit 80bfd186ae
4 changed files with 33 additions and 6 deletions

View file

@ -1055,7 +1055,8 @@ def update_items(lib, query, album, move, pretend):
def update_func(lib, opts, args):
update_items(lib, decargs(args), opts.album, opts.move, opts.pretend)
update_items(lib, decargs(args), opts.album, ui.should_move(opts.move),
opts.pretend)
update_cmd = ui.Subcommand(
@ -1064,7 +1065,11 @@ update_cmd = ui.Subcommand(
update_cmd.parser.add_album_option()
update_cmd.parser.add_format_option()
update_cmd.parser.add_option(
'-M', '--nomove', action='store_false', default=True, dest='move',
'-m', '--move', action='store_true', dest='move',
help="move files in the library directory"
)
update_cmd.parser.add_option(
'-M', '--nomove', action='store_false', dest='move',
help="don't move files in library"
)
update_cmd.parser.add_option(
@ -1294,14 +1299,18 @@ def modify_func(lib, opts, args):
if not mods and not dels:
raise ui.UserError('no modifications specified')
modify_items(lib, mods, dels, query, ui.should_write(opts.write),
opts.move, opts.album, not opts.yes)
ui.should_move(opts.move), opts.album, not opts.yes)
modify_cmd = ui.Subcommand(
'modify', help='change metadata fields', aliases=('mod',)
)
modify_cmd.parser.add_option(
'-M', '--nomove', action='store_false', default=True, dest='move',
'-m', '--move', action='store_true', dest='move',
help="move files in the library directory"
)
modify_cmd.parser.add_option(
'-M', '--nomove', action='store_false', dest='move',
help="don't move files in library"
)
modify_cmd.parser.add_option(

View file

@ -45,8 +45,11 @@ class MBSyncPlugin(BeetsPlugin):
help='update metadata from musicbrainz')
cmd.parser.add_option('-p', '--pretend', action='store_true',
help='show all changes but do nothing')
cmd.parser.add_option('-m', '--move', action='store_true',
dest='move',
help="move files in the library directory")
cmd.parser.add_option('-M', '--nomove', action='store_false',
default=True, dest='move',
dest='move',
help="don't move files in library")
cmd.parser.add_option('-W', '--nowrite', action='store_false',
default=None, dest='write',
@ -58,7 +61,7 @@ class MBSyncPlugin(BeetsPlugin):
def func(self, lib, opts, args):
"""Command handler for the mbsync function.
"""
move = opts.move
move = ui.should_move(opts.move)
pretend = opts.pretend
write = ui.should_write(opts.write)
query = ui.decargs(args)

View file

@ -4,6 +4,17 @@ Changelog
1.3.16 (in development)
-----------------------
New:
* Three commands, ``modify``, ``update``, and ``mbsync``, would previously
move files by default after changing their metadata. Now, these commands
will only move files if you have the :ref:`config-import-copy` or
:ref:`config-import-move` options enabled in your importer configuration.
This way, if you configure the importer not to touch your filenames, other
commands will respect that decision by default too. Each command also
sprouted a ``--move`` command-line option to override this default (in
addition to the ``--nomove`` flag they already had). :bug:`1697`
For developers:
* :doc:`/dev/plugins`: Two new hooks, ``albuminfo_received`` and

View file

@ -370,6 +370,8 @@ Either ``yes`` or ``no``, controlling whether metadata (e.g., ID3) tags are
written to files when using ``beet import``. Defaults to ``yes``. The ``-w``
and ``-W`` command-line options override this setting.
.. _config-import-copy:
copy
~~~~
@ -380,6 +382,8 @@ overridden with the ``-c`` and ``-C`` command-line options.
The option is ignored if ``move`` is enabled (i.e., beets can move or
copy files but it doesn't make sense to do both).
.. _config-import-move:
move
~~~~