Fix large ETA overflow C int
The following error was encountered in GTK3 which is a result of trying to cast a very large ETA value to C int and raising an Overlflow error. <type 'exceptions.OverflowError'>: 3072227291 not in range -2147483648 to 2147483647 The solution is to limit the ETA to 1 year and represent any values over that as -1 which the UIs can display as infinity.
This commit is contained in:
parent
5ec6ae3ad0
commit
d85f665091
|
@ -747,7 +747,8 @@ class Torrent(object):
|
|||
if left > 0:
|
||||
eta = left // status.download_payload_rate
|
||||
|
||||
return eta
|
||||
# Limit to 1 year, avoid excessive values and prevent GTK int overflow.
|
||||
return eta if eta < 31557600 else -1
|
||||
|
||||
def get_ratio(self):
|
||||
"""Get the ratio of upload/download for this torrent.
|
||||
|
|
|
@ -31,8 +31,10 @@ def format_speed(speed):
|
|||
def format_time(time):
|
||||
if time > 0:
|
||||
return deluge.common.ftime(time)
|
||||
else:
|
||||
elif time == 0:
|
||||
return '-'
|
||||
else:
|
||||
return '∞'
|
||||
|
||||
|
||||
def format_date_dash(time):
|
||||
|
|
|
@ -50,7 +50,12 @@ def fdate_or_dash(value):
|
|||
|
||||
def ftime_or_dash(value):
|
||||
"""Display value as time, eg 2h 30m or dash"""
|
||||
return ftime(value) if value > 0 else '-'
|
||||
if value > 0:
|
||||
return ftime(value)
|
||||
elif value == 0:
|
||||
return '-'
|
||||
else:
|
||||
return '∞'
|
||||
|
||||
|
||||
def fseed_rank_or_dash(seed_rank, seeding_time):
|
||||
|
|
|
@ -74,6 +74,10 @@
|
|||
return date > 0.0 ? fdate(date) : _('Never');
|
||||
}
|
||||
|
||||
function timeOrInf(time) {
|
||||
return time < 0 ? '∞' : ftime(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deluge.TorrentGrid Class
|
||||
*
|
||||
|
@ -154,7 +158,7 @@
|
|||
header: _('ETA'),
|
||||
width: 60,
|
||||
sortable: true,
|
||||
renderer: ftime,
|
||||
renderer: timeOrInf,
|
||||
dataIndex: 'eta',
|
||||
},
|
||||
{
|
||||
|
|
|
@ -102,7 +102,7 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
|
|||
upspeed: status.upload_payload_rate
|
||||
? fspeed(status.upload_payload_rate)
|
||||
: '0.0 KiB/s',
|
||||
eta: ftime(status.eta),
|
||||
eta: status.eta < 0 ? '∞' : ftime(status.eta),
|
||||
pieces: status.num_pieces + ' (' + fsize(status.piece_length) + ')',
|
||||
seeds: seeds,
|
||||
peers: peers,
|
||||
|
|
Loading…
Reference in New Issue