MCPcopy Index your code
hub / github.com/pimutils/vdirsyncer / sync

Method sync

tests/unit/sync/test_sync.py:583–632  ·  view source on GitHub ↗
(self, status, a, b, force_delete, conflict_resolution,
             with_error_callback, partial_sync)

Source from the content-addressed store, hash-verified

581 ))
582 )
583 def sync(self, status, a, b, force_delete, conflict_resolution,
584 with_error_callback, partial_sync):
585 assume(a is not b)
586 old_items_a = items(a)
587 old_items_b = items(b)
588
589 a.instance_name = 'a'
590 b.instance_name = 'b'
591
592 errors = []
593
594 if with_error_callback:
595 error_callback = errors.append
596 else:
597 error_callback = None
598
599 try:
600 # If one storage is read-only, double-sync because changes don't
601 # get reverted immediately.
602 for _ in range(2 if a.read_only or b.read_only else 1):
603 sync(a, b, status,
604 force_delete=force_delete,
605 conflict_resolution=conflict_resolution,
606 error_callback=error_callback,
607 partial_sync=partial_sync)
608
609 for e in errors:
610 raise e
611 except PartialSync:
612 assert partial_sync == 'error'
613 except ActionIntentionallyFailed:
614 pass
615 except BothReadOnly:
616 assert a.read_only and b.read_only
617 assume(False)
618 except StorageEmpty:
619 if force_delete:
620 raise
621 else:
622 assert not list(a.list()) or not list(b.list())
623 else:
624 items_a = items(a)
625 items_b = items(b)
626
627 assert items_a == items_b or partial_sync == 'ignore'
628 assert items_a == old_items_a or not a.read_only
629 assert items_b == old_items_b or not b.read_only
630
631 assert set(a.items) | set(b.items) == set(status) or \
632 partial_sync == 'ignore'
633
634
635TestSyncMachine = SyncMachine.TestCase

Callers 1

sync_collectionFunction · 0.80

Calls 3

itemsFunction · 0.85
syncFunction · 0.70
listMethod · 0.45

Tested by

no test coverage detected