mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
--force-delete is now a flag
Conflicts: tests/test_cli.py vdirsyncer/cli.py
This commit is contained in:
parent
a1f2d14c05
commit
ddc47c2272
2 changed files with 10 additions and 14 deletions
|
|
@ -155,14 +155,11 @@ def test_empty_storage(tmpdir):
|
|||
result = runner.invoke(cli.app, ['sync'])
|
||||
tmpdir.join('path_b/haha.txt').remove()
|
||||
result = runner.invoke(cli.app, ['sync'])
|
||||
assert result.output.splitlines() == [
|
||||
'Syncing my_pair',
|
||||
'error: {status_name}: Storage "{name}" was completely emptied. Use '
|
||||
'"--force-delete {status_name}" to synchronize that emptyness to '
|
||||
'the other side, or delete the status by yourself to restore the '
|
||||
'items from the non-empty side.'.format(status_name='my_pair',
|
||||
name='my_b')
|
||||
]
|
||||
lines = result.output.splitlines()
|
||||
assert len(lines) == 2
|
||||
assert lines[0] == 'Syncing my_pair'
|
||||
assert lines[1].startswith('error: my_pair: '
|
||||
'Storage "my_b" was completely emptied.')
|
||||
assert result.exception
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ def _create_app():
|
|||
|
||||
@app.command()
|
||||
@click.argument('pairs', nargs=-1)
|
||||
@click.option('--force-delete', multiple=True,
|
||||
@click.option('--force-delete/--no-force-delete',
|
||||
help=('Disable data-loss protection for the given pairs. '
|
||||
'Can be passed multiple times'))
|
||||
@click.option('--max-workers',
|
||||
|
|
@ -311,7 +311,6 @@ def _create_app():
|
|||
from the pair "bob".
|
||||
'''
|
||||
general, all_pairs, all_storages = ctx.obj['config']
|
||||
force_delete = set(force_delete)
|
||||
|
||||
cli_logger.debug('Using {} maximal workers.'.format(max_workers))
|
||||
wq = WorkerQueue(max_workers)
|
||||
|
|
@ -413,9 +412,9 @@ def handle_cli_error(status_name='sync'):
|
|||
except StorageEmpty as e:
|
||||
cli_logger.error(
|
||||
'{status_name}: Storage "{name}" was completely emptied. Use '
|
||||
'"--force-delete {status_name}" to synchronize that emptyness to '
|
||||
'the other side, or delete the status by yourself to restore the '
|
||||
'items from the non-empty side.'.format(
|
||||
'`vdirsyncer sync --force-delete {status_name}` to synchronize '
|
||||
'that emptyness to the other side, or delete the status by '
|
||||
'yourself to restore the items from the non-empty side.'.format(
|
||||
name=e.empty_storage.instance_name,
|
||||
status_name=status_name
|
||||
)
|
||||
|
|
@ -458,7 +457,7 @@ def sync_collection(wq, pair_name, collection, a, b, pair_options, general,
|
|||
sync(
|
||||
a, b, status,
|
||||
conflict_resolution=pair_options.get('conflict_resolution', None),
|
||||
force_delete=status_name in force_delete
|
||||
force_delete=force_delete
|
||||
)
|
||||
except:
|
||||
if not handle_cli_error(status_name):
|
||||
|
|
|
|||
Loading…
Reference in a new issue