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
20
oml/nodes.py
20
oml/nodes.py
|
|
@ -332,14 +332,18 @@ class Node(Thread):
|
|||
if since_ct > 1:
|
||||
ct = datetime.utcnow()
|
||||
t = Transfer.get(item.id)
|
||||
t.progress = len(content) / item.info['size']
|
||||
t.save()
|
||||
trigger_event('transfer', {
|
||||
'id': item.id, 'progress': t.progress
|
||||
})
|
||||
if state.bandwidth:
|
||||
state.bandwidth.download(size/since_ct)
|
||||
size = 0
|
||||
if not t.added:
|
||||
# transfer was canceled
|
||||
return False
|
||||
else:
|
||||
t.progress = len(content) / item.info['size']
|
||||
t.save()
|
||||
trigger_event('transfer', {
|
||||
'id': item.id, 'progress': t.progress
|
||||
})
|
||||
if state.bandwidth:
|
||||
state.bandwidth.download(size/since_ct)
|
||||
size = 0
|
||||
'''
|
||||
content = fileobj.read()
|
||||
'''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue