cancel active download and reset state if downloading again, fixes #187
This commit is contained in:
parent
cef4ce23e1
commit
52bc986260
2 changed files with 16 additions and 8 deletions
|
@ -378,6 +378,10 @@ class Item(db.Model):
|
||||||
u = state.user()
|
u = state.user()
|
||||||
if not u in self.users:
|
if not u in self.users:
|
||||||
t = Transfer.get_or_create(self.id)
|
t = Transfer.get_or_create(self.id)
|
||||||
|
if not t.added:
|
||||||
|
t.added = datetime.utcnow()
|
||||||
|
t.progress = 0
|
||||||
|
t.save()
|
||||||
logger.debug('queue %s for download', self.id)
|
logger.debug('queue %s for download', self.id)
|
||||||
self.add_user(u)
|
self.add_user(u)
|
||||||
|
|
||||||
|
|
20
oml/nodes.py
20
oml/nodes.py
|
@ -332,14 +332,18 @@ class Node(Thread):
|
||||||
if since_ct > 1:
|
if since_ct > 1:
|
||||||
ct = datetime.utcnow()
|
ct = datetime.utcnow()
|
||||||
t = Transfer.get(item.id)
|
t = Transfer.get(item.id)
|
||||||
t.progress = len(content) / item.info['size']
|
if not t.added:
|
||||||
t.save()
|
# transfer was canceled
|
||||||
trigger_event('transfer', {
|
return False
|
||||||
'id': item.id, 'progress': t.progress
|
else:
|
||||||
})
|
t.progress = len(content) / item.info['size']
|
||||||
if state.bandwidth:
|
t.save()
|
||||||
state.bandwidth.download(size/since_ct)
|
trigger_event('transfer', {
|
||||||
size = 0
|
'id': item.id, 'progress': t.progress
|
||||||
|
})
|
||||||
|
if state.bandwidth:
|
||||||
|
state.bandwidth.download(size/since_ct)
|
||||||
|
size = 0
|
||||||
'''
|
'''
|
||||||
content = fileobj.read()
|
content = fileobj.read()
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in a new issue