mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +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'])
|
result = runner.invoke(cli.app, ['sync'])
|
||||||
tmpdir.join('path_b/haha.txt').remove()
|
tmpdir.join('path_b/haha.txt').remove()
|
||||||
result = runner.invoke(cli.app, ['sync'])
|
result = runner.invoke(cli.app, ['sync'])
|
||||||
assert result.output.splitlines() == [
|
lines = result.output.splitlines()
|
||||||
'Syncing my_pair',
|
assert len(lines) == 2
|
||||||
'error: {status_name}: Storage "{name}" was completely emptied. Use '
|
assert lines[0] == 'Syncing my_pair'
|
||||||
'"--force-delete {status_name}" to synchronize that emptyness to '
|
assert lines[1].startswith('error: my_pair: '
|
||||||
'the other side, or delete the status by yourself to restore the '
|
'Storage "my_b" was completely emptied.')
|
||||||
'items from the non-empty side.'.format(status_name='my_pair',
|
|
||||||
name='my_b')
|
|
||||||
]
|
|
||||||
assert result.exception
|
assert result.exception
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,7 @@ def _create_app():
|
||||||
|
|
||||||
@app.command()
|
@app.command()
|
||||||
@click.argument('pairs', nargs=-1)
|
@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. '
|
help=('Disable data-loss protection for the given pairs. '
|
||||||
'Can be passed multiple times'))
|
'Can be passed multiple times'))
|
||||||
@click.option('--max-workers',
|
@click.option('--max-workers',
|
||||||
|
|
@ -311,7 +311,6 @@ def _create_app():
|
||||||
from the pair "bob".
|
from the pair "bob".
|
||||||
'''
|
'''
|
||||||
general, all_pairs, all_storages = ctx.obj['config']
|
general, all_pairs, all_storages = ctx.obj['config']
|
||||||
force_delete = set(force_delete)
|
|
||||||
|
|
||||||
cli_logger.debug('Using {} maximal workers.'.format(max_workers))
|
cli_logger.debug('Using {} maximal workers.'.format(max_workers))
|
||||||
wq = WorkerQueue(max_workers)
|
wq = WorkerQueue(max_workers)
|
||||||
|
|
@ -413,9 +412,9 @@ def handle_cli_error(status_name='sync'):
|
||||||
except StorageEmpty as e:
|
except StorageEmpty as e:
|
||||||
cli_logger.error(
|
cli_logger.error(
|
||||||
'{status_name}: Storage "{name}" was completely emptied. Use '
|
'{status_name}: Storage "{name}" was completely emptied. Use '
|
||||||
'"--force-delete {status_name}" to synchronize that emptyness to '
|
'`vdirsyncer sync --force-delete {status_name}` to synchronize '
|
||||||
'the other side, or delete the status by yourself to restore the '
|
'that emptyness to the other side, or delete the status by '
|
||||||
'items from the non-empty side.'.format(
|
'yourself to restore the items from the non-empty side.'.format(
|
||||||
name=e.empty_storage.instance_name,
|
name=e.empty_storage.instance_name,
|
||||||
status_name=status_name
|
status_name=status_name
|
||||||
)
|
)
|
||||||
|
|
@ -458,7 +457,7 @@ def sync_collection(wq, pair_name, collection, a, b, pair_options, general,
|
||||||
sync(
|
sync(
|
||||||
a, b, status,
|
a, b, status,
|
||||||
conflict_resolution=pair_options.get('conflict_resolution', None),
|
conflict_resolution=pair_options.get('conflict_resolution', None),
|
||||||
force_delete=status_name in force_delete
|
force_delete=force_delete
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
if not handle_cli_error(status_name):
|
if not handle_cli_error(status_name):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue