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()
|
||||
if not u in self.users:
|
||||
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)
|
||||
self.add_user(u)
|
||||
|
||||
|
|
|
@ -332,6 +332,10 @@ class Node(Thread):
|
|||
if since_ct > 1:
|
||||
ct = datetime.utcnow()
|
||||
t = Transfer.get(item.id)
|
||||
if not t.added:
|
||||
# transfer was canceled
|
||||
return False
|
||||
else:
|
||||
t.progress = len(content) / item.info['size']
|
||||
t.save()
|
||||
trigger_event('transfer', {
|
||||
|
|
Loading…
Reference in a new issue