Browse Source

Make use of new libtorrent feature to set file priorities before adding a torrent

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
b41bcdc605
  1. 22
      src/qtlibtorrent/qbtsession.cpp

22
src/qtlibtorrent/qbtsession.cpp

@ -1052,7 +1052,9 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
p.resume_data = &buf; p.resume_data = &buf;
qDebug("Successfully loaded fast resume data"); qDebug("Successfully loaded fast resume data");
} }
} else { }
#if LIBTORRENT_VERSION_MINOR < 16
else {
// Generate fake resume data to make sure unwanted files // Generate fake resume data to make sure unwanted files
// are not allocated // are not allocated
if(preAllocateAll) { if(preAllocateAll) {
@ -1065,6 +1067,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
} }
} }
} }
#endif
QString savePath; QString savePath;
if(!from_url.isEmpty() && savepathLabel_fromurl.contains(QUrl::fromEncoded(from_url.toUtf8()))) { 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 else
p.storage_mode = storage_mode_sparse; p.storage_mode = storage_mode_sparse;
// Priorities
#if LIBTORRENT_VERSION_MINOR > 15
if(TorrentTempData::hasTempData(hash)) {
std::vector<int> fp;
TorrentTempData::getFilesPriority(hash, fp);
if(!fp.empty()) {
std::vector<boost::uint8_t> *fp_conv = new std::vector<boost::uint8_t>();
for(uint i=0; i<fp.size(); ++i) {
fp_conv->push_back(fp[i]);
}
p.file_priorities = fp_conv;
}
}
#endif
// Start in pause // Start in pause
p.paused = true; p.paused = true;
p.duplicate_is_error = false; // Already checked 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 // The following is useless for newly added magnet
if(!magnet) { if(!magnet) {
#if LIBTORRENT_VERSION_MINOR < 16
// Files priorities // Files priorities
vector<int> fp; vector<int> fp;
TorrentTempData::getFilesPriority(hash, fp); TorrentTempData::getFilesPriority(hash, fp);
h.prioritize_files(fp); h.prioritize_files(fp);
#endif
// Prioritize first/last piece // Prioritize first/last piece
h.prioritize_first_last_piece(TorrentTempData::isSequential(hash)); h.prioritize_first_last_piece(TorrentTempData::isSequential(hash));

Loading…
Cancel
Save