Browse Source

- When incomplete torrents are saved to a different path, check if content is already present at final location

- Automacillay force a data recheck every time a torrent is moved (because libtorrent does not take care of checking if the torrent data exists at the destination location)
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
cac6f7428c
  1. 39
      src/bittorrent.cpp
  2. 2
      src/torrentpersistentdata.h

39
src/bittorrent.cpp

@ -763,12 +763,15 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) { @@ -763,12 +763,15 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
}
}
QString savePath = getSavePath(hash);
qDebug("addMagnetURI: using save_path: %s", savePath.toLocal8Bit().data());
if(defaultTempPath.isEmpty() || (resumed && TorrentPersistentData::isSeed(hash))) {
p.save_path = savePath.toLocal8Bit().data();
} else {
if(!defaultTempPath.isEmpty() && resumed && !TorrentPersistentData::isSeed(hash)) {
qDebug("addMagnetURI: Temp folder is enabled.");
p.save_path = defaultTempPath.toLocal8Bit().data();
qDebug("addMagnetURI: using save_path: %s", defaultTempPath.toLocal8Bit().data());
} else {
p.save_path = savePath.toLocal8Bit().data();
qDebug("addMagnetURI: using save_path: %s", savePath.toLocal8Bit().data());
}
#ifdef LIBTORRENT_0_15
// Skip checking and directly start seeding (new in libtorrent v0.15)
if(TorrentTempData::isSeedingMode(hash)){
@ -799,6 +802,13 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) { @@ -799,6 +802,13 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
return h;
}
Q_ASSERT(h.hash() == hash);
// If temp path is enabled, move torrent
if(!defaultTempPath.isEmpty() && !resumed) {
qDebug("Temp folder is enabled, moving new torrent to temp folder");
h.move_storage(defaultTempPath);
}
// Connections limit per torrent
h.set_max_connections(Preferences::getMaxConnecsPerTorrent());
// Uploads limit per torrent
@ -927,11 +937,13 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr @@ -927,11 +937,13 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
} else {
savePath = getSavePath(hash);
}
qDebug("addTorrent: using save_path: %s", savePath.toLocal8Bit().data());
if(defaultTempPath.isEmpty() || (resumed && TorrentPersistentData::isSeed(hash))) {
p.save_path = savePath.toLocal8Bit().data();
} else {
if(!defaultTempPath.isEmpty() && resumed && !TorrentPersistentData::isSeed(hash)) {
qDebug("addTorrent::Temp folder is enabled.");
p.save_path = defaultTempPath.toLocal8Bit().data();
qDebug("addTorrent: using save_path: %s", defaultTempPath.toLocal8Bit().data());
} else {
p.save_path = savePath.toLocal8Bit().data();
qDebug("addTorrent: using save_path: %s", savePath.toLocal8Bit().data());
}
#ifdef LIBTORRENT_0_15
@ -972,6 +984,12 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr @@ -972,6 +984,12 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
return h;
}
// If temp path is enabled, move torrent
if(!defaultTempPath.isEmpty() && !resumed) {
qDebug("Temp folder is enabled, moving new torrent to temp folder");
h.move_storage(defaultTempPath);
}
// Connections limit per torrent
h.set_max_connections(Preferences::getMaxConnecsPerTorrent());
// Uploads limit per torrent
@ -1704,6 +1722,11 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { @@ -1704,6 +1722,11 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
}
}
}
else if (storage_moved_alert* p = dynamic_cast<storage_moved_alert*>(a.get())) {
QTorrentHandle h(p->handle);
if(h.is_valid())
h.force_recheck(); //XXX: Required by libtorrent for now
}
else if (metadata_received_alert* p = dynamic_cast<metadata_received_alert*>(a.get())) {
QTorrentHandle h(p->handle);
if(h.is_valid()) {

2
src/torrentpersistentdata.h

@ -319,7 +319,7 @@ public: @@ -319,7 +319,7 @@ public:
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
QHash<QString, QVariant> data = all_data[hash].toHash();
return data["seed"].toBool();
return data.value("seed", false).toBool();
}
static bool isMagnet(QString hash) {

Loading…
Cancel
Save