Browse Source

BUGFIX: Fix ratio calculation for directly seeded torrents (Thanks phorane)

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
0f4f108eb5
  1. 6
      src/bittorrent.cpp
  2. 5
      src/qtorrenthandle.cpp
  3. 1
      src/qtorrenthandle.h

6
src/bittorrent.cpp

@ -1371,14 +1371,14 @@ bool Bittorrent::enableDHT(bool b) {
float Bittorrent::getRealRatio(QString hash) const{ float Bittorrent::getRealRatio(QString hash) const{
QTorrentHandle h = getTorrentHandle(hash); QTorrentHandle h = getTorrentHandle(hash);
Q_ASSERT(h.all_time_download() >= 0); Q_ASSERT(h.total_done() >= 0);
Q_ASSERT(h.all_time_upload() >= 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) if(h.all_time_upload() == 0)
return 0; return 0;
return 101; 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.); Q_ASSERT(ratio >= 0.);
if(ratio > 100.) if(ratio > 100.)
ratio = 100.; ratio = 100.;

5
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; 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() { size_type QTorrentHandle::all_time_download() {
Q_ASSERT(h.is_valid()); Q_ASSERT(h.is_valid());
return h.status().all_time_download; return h.status().all_time_download;

1
src/qtorrenthandle.h

@ -107,6 +107,7 @@ class QTorrentHandle {
size_type total_payload_upload(); size_type total_payload_upload();
size_type all_time_upload(); size_type all_time_upload();
size_type all_time_download(); size_type all_time_download();
size_type total_done();
QStringList files_path() const; QStringList files_path() const;
int num_uploads() const; int num_uploads() const;
bool is_seed() const; bool is_seed() const;

Loading…
Cancel
Save