diff --git a/Changelog b/Changelog index 1515cf16e..a39ffa1b3 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,8 @@ * Unreleased - Christophe Dumez - v2.0.6 - BUGFIX: Fix detection of invalid torrent files - BUGFIX: Stop catching signals once one has been caught to avoid possible infinite loop + - BUGFIX: Force data recheck whenever a torrent is moved + - BUGFIX: Detect existing torrent data even if incomplete torrents are saved to a different folder * Web Dec 31 2009 - Christophe Dumez - v2.0.5 - BUGFIX: Fix crash with downloaded/availability bars when the torrent has too many pieces diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index bff682f35..e304d257c 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -702,11 +702,13 @@ 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()); } // Preallocate all? if(preAllocateAll) @@ -730,6 +732,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 @@ -854,11 +863,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 @@ -899,6 +910,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 @@ -1495,6 +1512,11 @@ void Bittorrent::readAlerts() { } } } + else if (storage_moved_alert* p = dynamic_cast(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(a.get())) { QTorrentHandle h(p->handle); if(h.is_valid()) { diff --git a/src/torrentpersistentdata.h b/src/torrentpersistentdata.h index 97401a531..fed551300 100644 --- a/src/torrentpersistentdata.h +++ b/src/torrentpersistentdata.h @@ -249,7 +249,7 @@ public: QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); QHash all_data = settings.value("torrents", QHash()).toHash(); QHash data = all_data[hash].toHash(); - return data["seed"].toBool(); + return data.value("seed", false).toBool(); } static bool isMagnet(QString hash) {