diff --git a/src/FinishedTorrents.cpp b/src/FinishedTorrents.cpp index 6d081209b..e05a5f855 100644 --- a/src/FinishedTorrents.cpp +++ b/src/FinishedTorrents.cpp @@ -95,7 +95,7 @@ void FinishedTorrents::addTorrent(QString hash){ // Adding torrent to download list finishedListModel->insertRow(row); finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(h.name())); - finishedListModel->setData(finishedListModel->index(row, F_SIZE), QVariant((qlonglong)h.total_size())); + finishedListModel->setData(finishedListModel->index(row, F_SIZE), QVariant((qlonglong)h.actual_size())); finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)0.)); finishedListModel->setData(finishedListModel->index(row, F_SEEDSLEECH), QVariant("0/0")); finishedListModel->setData(finishedListModel->index(row, F_RATIO), QVariant(QString::fromUtf8(misc::toString(BTSession->getRealRatio(hash)).c_str()))); diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index bc20fe54d..5e8fdbb2a 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -72,10 +72,10 @@ bool QTorrentHandle::is_paused() const { return h.is_paused(); } -size_type QTorrentHandle::total_size() const { - Q_ASSERT(h.is_valid()); - return h.get_torrent_info().total_size(); -} +// size_type QTorrentHandle::total_size() const { +// Q_ASSERT(h.is_valid()); +// return h.get_torrent_info().total_size(); +// } size_type QTorrentHandle::total_done() const { Q_ASSERT(h.is_valid()); @@ -127,34 +127,14 @@ QStringList QTorrentHandle::url_seeds() const { // get the size of the torrent without the filtered files size_type QTorrentHandle::actual_size() const{ Q_ASSERT(h.is_valid()); - unsigned int nbFiles = h.get_torrent_info().num_files(); - if(!h.is_valid()){ - qDebug("/!\\ Error: Invalid handle"); - return h.get_torrent_info().total_size(); - } - QString hash = misc::toQString(h.get_torrent_info().info_hash()); - QFile pieces_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".priorities")); - // Read saved file - if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)){ - return h.get_torrent_info().total_size(); - } - QByteArray pieces_priorities = pieces_file.readAll(); - pieces_file.close(); - QList pieces_priorities_list = pieces_priorities.split('\n'); - if((unsigned int)pieces_priorities_list.size() != nbFiles+1){ - std::cerr << "* Error: Corrupted priorities file\n"; - return h.get_torrent_info().total_size(); - } - size_type effective_size = 0; - for(unsigned int i=0; i 7){ - priority = 1; - } - if(priority) - effective_size += h.get_torrent_info().file_at(i).size; + size_type size = 0; + std::vector piece_priorities = h.piece_priorities(); + for(unsigned int i = 0; i= 0 && size <= h.get_torrent_info().total_size()); + return size; } int QTorrentHandle::download_limit() const { diff --git a/src/qtorrenthandle.h b/src/qtorrenthandle.h index 78f57de43..33ceb0f9b 100644 --- a/src/qtorrenthandle.h +++ b/src/qtorrenthandle.h @@ -56,7 +56,7 @@ class QTorrentHandle { QString current_tracker() const; bool is_valid() const; bool is_paused() const; - size_type total_size() const; +// size_type total_size() const; size_type total_done() const; float download_payload_rate() const; float upload_payload_rate() const;