Fix identconflict handling

See #495
This commit is contained in:
Markus Unterwaditzer 2016-09-02 18:21:39 +02:00
parent 5a382be9c6
commit b6f009e79e

View file

@ -54,9 +54,9 @@ class IdentConflict(SyncError):
@hrefs.setter @hrefs.setter
def hrefs(self, val): def hrefs(self, val):
val = set(val) new_val = set(val)
assert len(val) > 1 assert len(new_val) > 1, val
self._hrefs = val self._hrefs = new_val
class StorageEmpty(SyncError): class StorageEmpty(SyncError):
@ -98,10 +98,11 @@ class StorageSyncer(object):
self.idents = {} self.idents = {}
def _store_props(ident, props): def _store_props(ident, props):
if self.idents.setdefault(ident, props) is not props: new_props = self.idents.setdefault(ident, props)
if new_props is not props:
raise IdentConflict(storage=self.storage, raise IdentConflict(storage=self.storage,
hrefs=[self.idents[ident]['href'], hrefs=[new_props['href'],
href]) props['href']])
if ident in self.status: if ident in self.status:
# Necessary if item's href changes. # Necessary if item's href changes.