diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 6ecb50755..4dfcd60fe 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -893,12 +893,7 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr if(!from_url.isNull()) QFile::remove(file); return h; } - // FIXME: Remove this debug - std::vector trackers = h.trackers(); - std::vector::iterator it; - for(it=trackers.begin(); it!=trackers.end(); it++) { - qDebug("* Tracker: %s", it->url.c_str()); - } + // Connections limit per torrent h.set_max_connections(Preferences::getMaxConnecsPerTorrent()); // Uploads limit per torrent @@ -910,6 +905,7 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr // Sequential download if(TorrentTempData::hasTempData(hash)) { qDebug("addTorrent: Setting download as sequential (from tmp data)"); + h.prioritize_files(TorrentTempData::getFilesPriority(hash)); h.set_sequential_download(TorrentTempData::isSequential(hash)); } // Save persistent data for new torrent diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index 138310594..c19438d28 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -472,7 +472,8 @@ void QTorrentHandle::set_max_connections(int val) { void QTorrentHandle::prioritize_files(std::vector v) { // Does not do anything for seeding torrents Q_ASSERT(h.is_valid()); - Q_ASSERT(v.size() == (unsigned int)h.get_torrent_info().num_files()); + if(v.size() != (unsigned int)h.get_torrent_info().num_files()) + return; h.prioritize_files(v); } diff --git a/src/torrentpersistentdata.h b/src/torrentpersistentdata.h index 2c06f0630..97401a531 100644 --- a/src/torrentpersistentdata.h +++ b/src/torrentpersistentdata.h @@ -36,6 +36,7 @@ #include #include "qtorrenthandle.h" #include "misc.h" +#include #ifdef QT_4_5 #include @@ -135,13 +136,18 @@ public: return QString::null; } - static QVariantList getFilesPriority(QString hash) { + static std::vector getFilesPriority(QString hash) { QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); QHash all_data = settings.value("torrents-tmp", QHash()).toHash(); QHash data = all_data[hash].toHash(); - if(data.contains("files_priority")) - return data["files_priority"].toList(); - return QVariantList(); + std::vector fp; + if(data.contains("files_priority")) { + QVariantList list_var = data["files_priority"].toList(); + foreach(const QVariant& var, list_var) { + fp.push_back(var.toInt()); + } + } + return fp; } };