mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-25 08:55:50 +00:00
Fix bugs in sync and add more tests
This commit is contained in:
parent
cc44b85e25
commit
89aeb27afb
2 changed files with 8 additions and 8 deletions
|
|
@ -13,8 +13,6 @@
|
|||
:license: MIT, see LICENSE for more details.
|
||||
'''
|
||||
|
||||
import itertools
|
||||
|
||||
def sync(storage_a, storage_b, status):
|
||||
'''Syncronizes two storages.
|
||||
|
||||
|
|
@ -67,14 +65,10 @@ def sync(storage_a, storage_b, status):
|
|||
del status[uid]
|
||||
|
||||
def get_actions(list_a, list_b, status):
|
||||
already_handled = set()
|
||||
prefetch_from_a = []
|
||||
prefetch_from_b = []
|
||||
actions = []
|
||||
for uid in itertools.chain(list_a, list_b, status):
|
||||
if uid in already_handled:
|
||||
continue
|
||||
already_handled.add(uid)
|
||||
for uid in set(list_a).union(set(list_b)).union(set(status)):
|
||||
if uid not in status:
|
||||
if uid in list_a and uid in list_b: # missing status
|
||||
# TODO: might need some kind of diffing too?
|
||||
|
|
@ -103,5 +97,4 @@ def get_actions(list_a, list_b, status):
|
|||
actions.append(('delete', uid, None, 'b'))
|
||||
elif uid not in list_a and uid not in list_b: # was deleted from a and b
|
||||
actions.append(('delete', uid, None, None))
|
||||
del status[uid]
|
||||
return actions, prefetch_from_a, prefetch_from_b
|
||||
|
|
|
|||
|
|
@ -61,3 +61,10 @@ class SyncTests(TestCase):
|
|||
assert next(b.list())[0] == '2'
|
||||
obj, uid, etag = b.get('2')
|
||||
assert obj.raw == new_item2.raw
|
||||
|
||||
def test_irrelevant_status(self):
|
||||
a = MemoryStorage()
|
||||
b = MemoryStorage()
|
||||
status = {'1': ('UID:1', 1234)}
|
||||
sync(a, b, status)
|
||||
assert not status
|
||||
|
|
|
|||
Loading…
Reference in a new issue