diff --git a/vdirsyncer/sync.py b/vdirsyncer/sync.py index 06ce729..05f9b8d 100644 --- a/vdirsyncer/sync.py +++ b/vdirsyncer/sync.py @@ -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 diff --git a/vdirsyncer/tests/test_sync.py b/vdirsyncer/tests/test_sync.py index c48a7e9..b28fbf7 100644 --- a/vdirsyncer/tests/test_sync.py +++ b/vdirsyncer/tests/test_sync.py @@ -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