download progress
This commit is contained in:
parent
9a6278bb83
commit
eac91e7a3a
1 changed files with 11 additions and 8 deletions
19
oml/nodes.py
19
oml/nodes.py
|
@ -306,18 +306,21 @@ class Node(Thread):
|
||||||
if r.headers.get('content-encoding', None) == 'gzip':
|
if r.headers.get('content-encoding', None) == 'gzip':
|
||||||
content = gzip.GzipFile(fileobj=r).read()
|
content = gzip.GzipFile(fileobj=r).read()
|
||||||
else:
|
else:
|
||||||
'''
|
|
||||||
content = ''
|
content = ''
|
||||||
for chunk in iter(lambda: r.read(1024*1024), ''):
|
ct = datetime.utcnow()
|
||||||
t = Transfer.get(item.id)
|
for chunk in iter(lambda: r.read(16*1024), ''):
|
||||||
content += chunk
|
content += chunk
|
||||||
t.progress = len(content) / item.info['size']
|
if (datetime.utcnow() - ct).total_seconds() > 1:
|
||||||
t.save()
|
ct = datetime.utcnow()
|
||||||
trigger_event('transfer', {
|
t = Transfer.get(item.id)
|
||||||
'id': item.id, 'progress': t.progress
|
t.progress = len(content) / item.info['size']
|
||||||
})
|
t.save()
|
||||||
|
trigger_event('transfer', {
|
||||||
|
'id': item.id, 'progress': t.progress
|
||||||
|
})
|
||||||
'''
|
'''
|
||||||
content = r.read()
|
content = r.read()
|
||||||
|
'''
|
||||||
|
|
||||||
t2 = datetime.utcnow()
|
t2 = datetime.utcnow()
|
||||||
duration = (t2-t1).total_seconds()
|
duration = (t2-t1).total_seconds()
|
||||||
|
|
Loading…
Reference in a new issue