fix resync
This commit is contained in:
parent
3845189b4c
commit
adf2eef34a
1 changed files with 6 additions and 6 deletions
|
@ -71,12 +71,13 @@ class Changelog(db.Model):
|
||||||
logger.debug('record change: %s', c.json())
|
logger.debug('record change: %s', c.json())
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def apply_changes(cls, user, changes, first=False):
|
def apply_changes(cls, user_, changes, first=False):
|
||||||
|
from user.models import User
|
||||||
|
user = user_
|
||||||
trigger = changes
|
trigger = changes
|
||||||
if trigger:
|
if trigger:
|
||||||
trigger_event('change', {})
|
trigger_event('change', {})
|
||||||
if first:
|
if first:
|
||||||
logger.debug('remove left over items')
|
|
||||||
items = set()
|
items = set()
|
||||||
lists = {}
|
lists = {}
|
||||||
peers = set()
|
peers = set()
|
||||||
|
@ -103,12 +104,11 @@ class Changelog(db.Model):
|
||||||
qs = user.lists.filter_by(name=name)
|
qs = user.lists.filter_by(name=name)
|
||||||
if qs.count():
|
if qs.count():
|
||||||
l = qs[0]
|
l = qs[0]
|
||||||
remove = []
|
|
||||||
for i in l.get_items():
|
for i in l.get_items():
|
||||||
if i.id not in lists[name]:
|
if i.id not in lists[name]:
|
||||||
remove.append(i.id)
|
if i.id in l.items:
|
||||||
l.items.remove(i.id)
|
l.items.remove(i.id)
|
||||||
for peer in user.models.Users.query:
|
for peer in User.query:
|
||||||
if user.id in peer.info.get('users', {}) and peer.id not in peers:
|
if user.id in peer.info.get('users', {}) and peer.id not in peers:
|
||||||
del peer.info['users'][user.id]
|
del peer.info['users'][user.id]
|
||||||
peer.save()
|
peer.save()
|
||||||
|
|
Loading…
Reference in a new issue