From be6099a7971ca3328e7ce9518e1f7d5b3e4fb677 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 17 Feb 2010 08:13:47 +0000 Subject: [PATCH] BUGFIX: Fix ratio calculation for directly seeded torrents (Thanks phorane) --- Changelog | 1 + src/bittorrent.cpp | 6 +++--- src/eventmanager.cpp | 4 +++- src/qtorrenthandle.cpp | 5 +++++ src/qtorrenthandle.h | 1 + 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index 874af7197..e26390802 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,7 @@ * Unreleased - Christophe Dumez - v2.1.6 - BUGFIX: Fix Web UI authentication with Konqueror - BUGFIX: Fix save path display in properties + - BUGFIX: Fix ratio calculation for directly seeded torrents (Thanks phorane) * Web Feb 10 2010 - Christophe Dumez - v2.1.5 - BUGFIX: Fix actions on selected torrents (non-selected torrents could be affected) diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 8a361edda..d5bdcf229 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -1232,14 +1232,14 @@ bool Bittorrent::enableDHT(bool b) { float Bittorrent::getRealRatio(QString hash) const{ QTorrentHandle h = getTorrentHandle(hash); - Q_ASSERT(h.all_time_download() >= 0); + Q_ASSERT(h.total_done() >= 0); Q_ASSERT(h.all_time_upload() >= 0); - if(h.all_time_download() == 0) { + if(h.total_done() == 0) { if(h.all_time_upload() == 0) return 0; return 101; } - float ratio = (float)h.all_time_upload()/(float)h.all_time_download(); + float ratio = (float)h.all_time_upload()/(float)h.total_done(); Q_ASSERT(ratio >= 0.); if(ratio > 100.) ratio = 100.; diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp index 3d3025f0d..edddd42e4 100644 --- a/src/eventmanager.cpp +++ b/src/eventmanager.cpp @@ -282,7 +282,9 @@ QVariantMap EventManager::getPropGeneralInfo(QString hash) const { QTorrentHandle h = BTSession->getTorrentHandle(hash); if(h.is_valid() && h.has_metadata()) { // Save path - data["save_path"] = TorrentPersistentData::getSavePath(hash); + QString p = TorrentPersistentData::getSavePath(hash); + if(p.isEmpty()) p = h.save_path(); + data["save_path"] = p; // Creation date data["creation_date"] = h.creation_date(); // Comment diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index 6d29387dc..558dc83ed 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -336,6 +336,11 @@ bool QTorrentHandle::is_checking() const { return h.status().state == torrent_status::checking_files || h.status().state == torrent_status::checking_resume_data; } +size_type QTorrentHandle::total_done() { + Q_ASSERT(h.is_valid()); + return h.status().total_done; +} + size_type QTorrentHandle::all_time_download() { Q_ASSERT(h.is_valid()); return h.status().all_time_download; diff --git a/src/qtorrenthandle.h b/src/qtorrenthandle.h index 19fcf00ef..b07041e49 100644 --- a/src/qtorrenthandle.h +++ b/src/qtorrenthandle.h @@ -107,6 +107,7 @@ class QTorrentHandle { size_type total_payload_upload(); size_type all_time_upload(); size_type all_time_download(); + size_type total_done(); QStringList files_path() const; int num_uploads() const; bool is_seed() const;