mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-08 01:18:39 +00:00
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
5 changed files with 17 additions and 5 deletions
|
@ -747,7 +747,8 @@ class Torrent(object):
|
||||||
if left > 0:
|
if left > 0:
|
||||||
eta = left // status.download_payload_rate
|
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):
|
def get_ratio(self):
|
||||||
"""Get the ratio of upload/download for this torrent.
|
"""Get the ratio of upload/download for this torrent.
|
||||||
|
|
|
@ -31,8 +31,10 @@ def format_speed(speed):
|
||||||
def format_time(time):
|
def format_time(time):
|
||||||
if time > 0:
|
if time > 0:
|
||||||
return deluge.common.ftime(time)
|
return deluge.common.ftime(time)
|
||||||
else:
|
elif time == 0:
|
||||||
return '-'
|
return '-'
|
||||||
|
else:
|
||||||
|
return '∞'
|
||||||
|
|
||||||
|
|
||||||
def format_date_dash(time):
|
def format_date_dash(time):
|
||||||
|
|
|
@ -50,7 +50,12 @@ def fdate_or_dash(value):
|
||||||
|
|
||||||
def ftime_or_dash(value):
|
def ftime_or_dash(value):
|
||||||
"""Display value as time, eg 2h 30m or dash"""
|
"""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):
|
def fseed_rank_or_dash(seed_rank, seeding_time):
|
||||||
|
|
|
@ -74,6 +74,10 @@
|
||||||
return date > 0.0 ? fdate(date) : _('Never');
|
return date > 0.0 ? fdate(date) : _('Never');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function timeOrInf(time) {
|
||||||
|
return time < 0 ? '∞' : ftime(time);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deluge.TorrentGrid Class
|
* Deluge.TorrentGrid Class
|
||||||
*
|
*
|
||||||
|
@ -154,7 +158,7 @@
|
||||||
header: _('ETA'),
|
header: _('ETA'),
|
||||||
width: 60,
|
width: 60,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
renderer: ftime,
|
renderer: timeOrInf,
|
||||||
dataIndex: 'eta',
|
dataIndex: 'eta',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,7 +102,7 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
|
||||||
upspeed: status.upload_payload_rate
|
upspeed: status.upload_payload_rate
|
||||||
? fspeed(status.upload_payload_rate)
|
? fspeed(status.upload_payload_rate)
|
||||||
: '0.0 KiB/s',
|
: '0.0 KiB/s',
|
||||||
eta: ftime(status.eta),
|
eta: status.eta < 0 ? '∞' : ftime(status.eta),
|
||||||
pieces: status.num_pieces + ' (' + fsize(status.piece_length) + ')',
|
pieces: status.num_pieces + ' (' + fsize(status.piece_length) + ')',
|
||||||
seeds: seeds,
|
seeds: seeds,
|
||||||
peers: peers,
|
peers: peers,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue