From 31bb4eface756f39365ee06afd354d17ab63baac Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 14 Jul 2008 23:17:20 +0000 Subject: [PATCH] Fix displaying file percentages properly. --- deluge/core/torrent.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 448cf435f..fecfe8016 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -365,7 +365,16 @@ class Torrent: def get_queue_position(self): """Returns the torrents queue position""" return self.handle.queue_position() + + def get_file_progress(self): + """Returns the file progress as a list of floats.. 0.0 -> 1.0""" + file_progress = self.handle.file_progress() + ret = [] + for i,f in enumerate(self.files): + ret.append(file_progress[i] / f["size"]) + return ret + def get_status(self, keys): """Returns the status of the torrent based on the keys provided""" # Create the full dictionary @@ -429,7 +438,7 @@ class Torrent: "piece_length": self.torrent_info.piece_length, "eta": self.get_eta, "ratio": self.get_ratio, - "file_progress": self.handle.file_progress, + "file_progress": self.get_file_progress, "queue": self.handle.queue_position, "is_seed": self.handle.is_seed, "peers": self.get_peers,