mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Use multiple connections when syncing.
This commit is contained in:
parent
d7b58d21dd
commit
f8c2c8f879
2 changed files with 36 additions and 15 deletions
|
|
@ -5,6 +5,12 @@
|
|||
# A folder where vdirsyncer can store some metadata about each pair.
|
||||
status_path = ~/.vdirsyncer/status/
|
||||
|
||||
# The amount of processes to use when synchronizing. If the CPU of your server
|
||||
# is the bottleneck (which is plausible for small homeservers), set this to the
|
||||
# number of cores * 2. Defaults to one process for each collection. The value
|
||||
# 0 will be ignored.
|
||||
#processes =
|
||||
|
||||
# CONTACTS
|
||||
[pair bob_contacts]
|
||||
# Similar to accounts in OfflineIMAP.
|
||||
|
|
|
|||
|
|
@ -190,23 +190,38 @@ def _main(env, file_cfg):
|
|||
config_a.update(all_storages[a_name])
|
||||
config_b = dict(storage_defaults)
|
||||
config_b.update(all_storages[b_name])
|
||||
a = storage_instance_from_config(config_a)
|
||||
b = storage_instance_from_config(config_b)
|
||||
|
||||
def x(a=a, b=b, pair_name=pair_name, collection=collection):
|
||||
status_name = \
|
||||
'_'.join(filter(bool, (pair_name, collection)))
|
||||
pair_description = \
|
||||
' from '.join(filter(bool, (collection, pair_name)))
|
||||
cli_logger.info('Syncing {}'.format(pair_description))
|
||||
status = load_status(general['status_path'], status_name)
|
||||
sync(a, b, status,
|
||||
pair_options.get('conflict_resolution', None))
|
||||
save_status(general['status_path'], status_name, status)
|
||||
actions.append(x)
|
||||
|
||||
for action in actions:
|
||||
action()
|
||||
actions.append({
|
||||
'config_a': config_a,
|
||||
'config_b': config_b,
|
||||
'pair_name': pair_name,
|
||||
'collection': collection,
|
||||
'pair_options': pair_options,
|
||||
'general': general
|
||||
})
|
||||
|
||||
from multiprocessing import Pool
|
||||
p = Pool(processes=general.get('processes', 0) or len(actions))
|
||||
p.map(_sync_collection, actions)
|
||||
|
||||
app.register_command('sync', sync_command)
|
||||
app()
|
||||
|
||||
def _sync_collection(x):
|
||||
return sync_collection(**x)
|
||||
|
||||
def sync_collection(config_a, config_b, pair_name, collection, pair_options,
|
||||
general):
|
||||
a = storage_instance_from_config(config_a)
|
||||
b = storage_instance_from_config(config_b)
|
||||
|
||||
status_name = \
|
||||
'_'.join(filter(bool, (pair_name, collection)))
|
||||
pair_description = \
|
||||
' from '.join(filter(bool, (collection, pair_name)))
|
||||
cli_logger.info('Syncing {}'.format(pair_description))
|
||||
status = load_status(general['status_path'], status_name)
|
||||
sync(a, b, status,
|
||||
pair_options.get('conflict_resolution', None))
|
||||
save_status(general['status_path'], status_name, status)
|
||||
|
|
|
|||
Loading…
Reference in a new issue