From b41bcdc605cf7d0feed70934715d641af876a68e Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sun, 17 Apr 2011 15:27:18 +0000 Subject: [PATCH] Make use of new libtorrent feature to set file priorities before adding a torrent --- src/qtlibtorrent/qbtsession.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index fcda5a8bd..ef564b159 100644 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -1052,7 +1052,9 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr p.resume_data = &buf; qDebug("Successfully loaded fast resume data"); } - } else { + } +#if LIBTORRENT_VERSION_MINOR < 16 + else { // Generate fake resume data to make sure unwanted files // are not allocated if(preAllocateAll) { @@ -1065,6 +1067,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr } } } +#endif QString savePath; if(!from_url.isEmpty() && savepathLabel_fromurl.contains(QUrl::fromEncoded(from_url.toUtf8()))) { @@ -1215,6 +1218,21 @@ add_torrent_params QBtSession::initializeAddTorrentParams(const QString &hash) { else p.storage_mode = storage_mode_sparse; + // Priorities +#if LIBTORRENT_VERSION_MINOR > 15 + if(TorrentTempData::hasTempData(hash)) { + std::vector fp; + TorrentTempData::getFilesPriority(hash, fp); + if(!fp.empty()) { + std::vector *fp_conv = new std::vector(); + for(uint i=0; ipush_back(fp[i]); + } + p.file_priorities = fp_conv; + } + } +#endif + // Start in pause p.paused = true; p.duplicate_is_error = false; // Already checked @@ -1233,10 +1251,12 @@ void QBtSession::loadTorrentTempData(QTorrentHandle &h, QString savePath, bool m // The following is useless for newly added magnet if(!magnet) { +#if LIBTORRENT_VERSION_MINOR < 16 // Files priorities vector fp; TorrentTempData::getFilesPriority(hash, fp); h.prioritize_files(fp); +#endif // Prioritize first/last piece h.prioritize_first_last_piece(TorrentTempData::isSequential(hash));