mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-03-26 09:05:50 +00:00
Fix bug during prefetch
The idea that prefetching isn't necessary if the other storage can't be written to is wrong, we still need to prefetch for UID-matching
This commit is contained in:
parent
b7542fb536
commit
ed22764921
2 changed files with 21 additions and 4 deletions
|
|
@ -41,6 +41,7 @@ def test_missing_status():
|
|||
def test_missing_status_and_different_items():
|
||||
a = MemoryStorage()
|
||||
b = MemoryStorage()
|
||||
|
||||
status = {}
|
||||
item1 = Item(u'UID:1\nhaha')
|
||||
item2 = Item(u'UID:1\nhoho')
|
||||
|
|
@ -54,6 +55,22 @@ def test_missing_status_and_different_items():
|
|||
assert_item_equals(item1, a.get('1')[0])
|
||||
|
||||
|
||||
def test_read_only_and_prefetch():
|
||||
a = MemoryStorage()
|
||||
b = MemoryStorage()
|
||||
b.read_only = True
|
||||
|
||||
status = {}
|
||||
item1 = Item(u'UID:1\nhaha')
|
||||
item2 = Item(u'UID:2\nhoho')
|
||||
a.upload(item1)
|
||||
a.upload(item2)
|
||||
|
||||
sync(a, b, status, force_delete=True)
|
||||
sync(a, b, status, force_delete=True)
|
||||
|
||||
assert list(a.list()) == list(b.list()) == []
|
||||
|
||||
def test_upload_and_update():
|
||||
a = MemoryStorage(fileext='.a')
|
||||
b = MemoryStorage(fileext='.b')
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class StorageSyncer(object):
|
|||
self.status = status
|
||||
self.idents = None
|
||||
|
||||
def prepare_idents(self, other_read_only):
|
||||
def prepare_idents(self):
|
||||
href_to_status = dict((href, (ident, etag))
|
||||
for ident, (href, etag)
|
||||
in iteritems(self.status))
|
||||
|
|
@ -105,7 +105,7 @@ class StorageSyncer(object):
|
|||
props = {'href': href, 'etag': etag}
|
||||
ident, old_etag = href_to_status.get(href, (None, None))
|
||||
assert etag is not None
|
||||
if etag != old_etag and not other_read_only:
|
||||
if etag != old_etag:
|
||||
# Either the item is completely new, or updated
|
||||
# In both cases we should prefetch
|
||||
prefetch[href] = props
|
||||
|
|
@ -165,8 +165,8 @@ def sync(storage_a, storage_b, status, conflict_resolution=None,
|
|||
for ident, (href_a, etag_a, href_b, etag_b) in iteritems(status)
|
||||
))
|
||||
|
||||
a_info.prepare_idents(storage_b.read_only)
|
||||
b_info.prepare_idents(storage_a.read_only)
|
||||
a_info.prepare_idents()
|
||||
b_info.prepare_idents()
|
||||
|
||||
if bool(a_info.idents) != bool(b_info.idents) \
|
||||
and status and not force_delete:
|
||||
|
|
|
|||
Loading…
Reference in a new issue