diff --git a/src/common.py b/src/common.py index 71a5ddc9d..811111357 100644 --- a/src/common.py +++ b/src/common.py @@ -39,12 +39,14 @@ PLUGIN_DIR = os.path.join(INSTALL_PREFIX, 'share', 'deluge', 'plugins') def estimate_eta(state): try: - return ftime(get_eta(state["total_size"], state["total_payload_download"], state["download_rate"])) + return ftime(get_eta(state["total_size"], state["total_done"], state["download_rate"])) except ZeroDivisionError: return _("Infinity") def get_eta(size, done, rate): - return long( (size - done) / rate ) + if (size - done) == 0: + raise ZeroDivisionError + return (size - done) / rate # Returns formatted string describing filesize # fsize_b should be in bytes diff --git a/src/deluge_core.cpp b/src/deluge_core.cpp index e3212f3ae..10797d503 100644 --- a/src/deluge_core.cpp +++ b/src/deluge_core.cpp @@ -620,7 +620,7 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args) long connected_peers = s.num_peers - connected_seeds; - return Py_BuildValue("{s:s,s:l,s:l,s:l,s:l,s:f,s:f,s:i,s:f,s:i,s:l,s:s,s:s,s:f,s:i,s:i,s:l,s:l,s:l,s:d,s:l,s:l,s:l,s:l,s:l,s:l,s:i,s:d,s:d}", + return Py_BuildValue("{s:s,s:l,s:l,s:l,s:l,s:f,s:f,s:i,s:f,s:i,s:l,s:s,s:s,s:f,s:i,s:i,s:l,s:l,s:l,s:i,s:l,s:l,s:l,s:l,s:l,s:l,s:i,s:d,s:d}", "name", t.handle.get_torrent_info().name().c_str(), "num_files", t.handle.get_torrent_info().num_files(), "state", s.state, @@ -640,7 +640,7 @@ static PyObject *torrent_get_torrent_state(PyObject *self, PyObject *args) "pieces", long(s.pieces), "pieces_done", long(s.num_pieces), "block_size", long(s.block_size), - "total_size", double(i.total_size()), + "total_size", int(i.total_size()), "piece_length", long(i.piece_length()), "num_pieces", long(i.num_pieces()), "total_peers", long(s.num_incomplete != -1? s.num_incomplete : connected_peers), diff --git a/src/interface.py b/src/interface.py index 7fd627a1b..585bbe5f4 100644 --- a/src/interface.py +++ b/src/interface.py @@ -319,10 +319,8 @@ class DelugeGTK: def time(column, cell, model, iter, data): time = int(model.get_value(iter, data)) - if time < 0: + if time < 0 or time == 0: time_str = _("Infinity") - elif time == 0: - time_str = "-" else: time_str = common.ftime(time) cell.set_property('text', time_str) @@ -574,9 +572,9 @@ class DelugeGTK: dlrate = int(state['download_rate']) ulrate = int(state['upload_rate']) try: - eta = common.get_eta(state["total_size"], state["total_download"], state["download_rate"]) + eta = common.get_eta(state["total_size"], state["total_done"], state["download_rate"]) except ZeroDivisionError: - eta = -1 + eta = 0 share = float(self.calc_share_ratio(unique_id, state)) rlist = [int(unique_id), int(queue), str(name), long(size), float(progress), str(message), int(seeds), int(seeds_t), int(peers), int(peers_t), int(dlrate), int(ulrate), int(eta), float(share)]