pull changes while offline
This commit is contained in:
parent
130a900bb0
commit
ba4f311fe1
1 changed files with 10 additions and 4 deletions
14
oml/nodes.py
14
oml/nodes.py
|
@ -169,6 +169,8 @@ class Node(Thread):
|
|||
def can_connect(self):
|
||||
self.resolve()
|
||||
url = self.url
|
||||
if not state.online and not self.local:
|
||||
return False
|
||||
try:
|
||||
if url:
|
||||
headers = {
|
||||
|
@ -233,6 +235,11 @@ class Node(Thread):
|
|||
})
|
||||
|
||||
def pullChanges(self):
|
||||
if state.shutdown:
|
||||
return
|
||||
self.online = self.can_connect()
|
||||
if not self.online or state.shutdown:
|
||||
return
|
||||
with db.session():
|
||||
u = user.models.User.get_or_create(self.user_id)
|
||||
if not u or not self.online or not u.peered:
|
||||
|
@ -476,6 +483,8 @@ class Nodes(Thread):
|
|||
return
|
||||
self._pulling = True
|
||||
library.sync_db()
|
||||
if state.shutdown:
|
||||
return
|
||||
users = []
|
||||
with db.session():
|
||||
from user.models import User
|
||||
|
@ -487,10 +496,7 @@ class Nodes(Thread):
|
|||
break
|
||||
node = self._nodes.get(u['id'])
|
||||
if node:
|
||||
if not state.shutdown:
|
||||
node.online = node.can_connect()
|
||||
if not state.shutdown and node.online:
|
||||
node.pullChanges()
|
||||
node.pullChanges()
|
||||
self._pulling = False
|
||||
|
||||
def run(self):
|
||||
|
|
Loading…
Reference in a new issue