fix addpeer
This commit is contained in:
parent
5a417baf16
commit
c66433c740
2 changed files with 9 additions and 3 deletions
|
@ -302,6 +302,7 @@ class Changelog(db.Model):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def aggregated_changes(cls, since=None, user_id=None):
|
def aggregated_changes(cls, since=None, user_id=None):
|
||||||
|
from item.models import Item
|
||||||
from user.models import List
|
from user.models import List
|
||||||
if not user_id:
|
if not user_id:
|
||||||
user_id = settings.USER_ID
|
user_id = settings.USER_ID
|
||||||
|
@ -325,6 +326,9 @@ class Changelog(db.Model):
|
||||||
action[item_id] = [revision, timestamp, info]
|
action[item_id] = [revision, timestamp, info]
|
||||||
if item_id in changes.get('removeitem', []):
|
if item_id in changes.get('removeitem', []):
|
||||||
del changes['removeitem'][item_id]
|
del changes['removeitem'][item_id]
|
||||||
|
i = Item.get(item_id)
|
||||||
|
if i:
|
||||||
|
changes.setdefault('edititem', {})[item_id] = [revision+1, timestamp, i.meta]
|
||||||
elif op == 'edititem':
|
elif op == 'edititem':
|
||||||
item_id = data[1]
|
item_id = data[1]
|
||||||
meta = data[2]
|
meta = data[2]
|
||||||
|
@ -413,8 +417,8 @@ class Changelog(db.Model):
|
||||||
pass
|
pass
|
||||||
elif op == 'addpeer':
|
elif op == 'addpeer':
|
||||||
peer = data[1]
|
peer = data[1]
|
||||||
info = data[2]
|
username = data[2]
|
||||||
action[peer] = [timestamp, info]
|
action[peer] = [revision, timestamp, username]
|
||||||
if peer in changes.get('removepeer', []):
|
if peer in changes.get('removepeer', []):
|
||||||
del changes['removepeer'][peer]
|
del changes['removepeer'][peer]
|
||||||
elif op == 'removepeer':
|
elif op == 'removepeer':
|
||||||
|
|
|
@ -54,6 +54,7 @@ class Node(Thread):
|
||||||
self._pull = PeriodicCallback(self.pull, 60000)
|
self._pull = PeriodicCallback(self.pull, 60000)
|
||||||
self._pull.start()
|
self._pull.start()
|
||||||
self.ping()
|
self.ping()
|
||||||
|
self.pull()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while self._running:
|
while self._running:
|
||||||
|
@ -68,7 +69,8 @@ class Node(Thread):
|
||||||
elif action == 'pull':
|
elif action == 'pull':
|
||||||
self._pulling = True
|
self._pulling = True
|
||||||
self.online = self.can_connect()
|
self.online = self.can_connect()
|
||||||
self.pullChanges()
|
if self.online:
|
||||||
|
self.pullChanges()
|
||||||
self._pulling = False
|
self._pulling = False
|
||||||
else:
|
else:
|
||||||
logger.debug('unknown action %s', action)
|
logger.debug('unknown action %s', action)
|
||||||
|
|
Loading…
Reference in a new issue