Browse Source

- Torrent Addition Dialog: File priorities were not taken into consideration (Thanks Mariusz)

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
abbbf1e562
  1. 8
      src/bittorrent.cpp
  2. 3
      src/qtorrenthandle.cpp
  3. 14
      src/torrentpersistentdata.h

8
src/bittorrent.cpp

@ -893,12 +893,7 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr @@ -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<announce_entry> trackers = h.trackers();
std::vector<announce_entry>::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 @@ -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

3
src/qtorrenthandle.cpp

@ -472,7 +472,8 @@ void QTorrentHandle::set_max_connections(int val) { @@ -472,7 +472,8 @@ void QTorrentHandle::set_max_connections(int val) {
void QTorrentHandle::prioritize_files(std::vector<int> 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);
}

14
src/torrentpersistentdata.h

@ -36,6 +36,7 @@ @@ -36,6 +36,7 @@
#include <libtorrent/magnet_uri.hpp>
#include "qtorrenthandle.h"
#include "misc.h"
#include <vector>
#ifdef QT_4_5
#include <QHash>
@ -135,13 +136,18 @@ public: @@ -135,13 +136,18 @@ public:
return QString::null;
}
static QVariantList getFilesPriority(QString hash) {
static std::vector<int> getFilesPriority(QString hash) {
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
if(data.contains("files_priority"))
return data["files_priority"].toList();
return QVariantList();
std::vector<int> 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;
}
};

Loading…
Cancel
Save