cleanup download, download from local nodes if offline, cache per download users syndb only at startup
This commit is contained in:
parent
ba4f311fe1
commit
988d030f92
4 changed files with 45 additions and 42 deletions
|
|
@ -45,22 +45,24 @@ class Downloads(Thread):
|
|||
if itemid not in self.transfers:
|
||||
continue
|
||||
if t.get('added') and t.get('progress', -1) < 1:
|
||||
i = item.models.Item.get(itemid)
|
||||
for u in i.users:
|
||||
if not 'users' in t:
|
||||
i = item.models.Item.get(itemid)
|
||||
t['users'] = [u.id for u in i.users]
|
||||
for uid in t['users']:
|
||||
if state.shutdown:
|
||||
return False
|
||||
if state.nodes.is_online(u.id):
|
||||
logger.debug('DOWNLOAD %s %s', i, u)
|
||||
r = state.nodes.download(u.id, i)
|
||||
if state.nodes.is_online(uid):
|
||||
logger.debug('DOWNLOAD %s %s', i, uid)
|
||||
if state.nodes.download(uid, i):
|
||||
break
|
||||
return False
|
||||
|
||||
def run(self):
|
||||
self.wait(10)
|
||||
while not state.shutdown:
|
||||
if self.wait_online():
|
||||
with db.session():
|
||||
self.download_next()
|
||||
self.wait(10)
|
||||
with db.session():
|
||||
self.download_next()
|
||||
self.wait(10)
|
||||
|
||||
def join(self):
|
||||
self.transfers.commit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue