diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 35fa11b73..6fbaa2a48 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -1915,12 +1915,30 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { } emit torrentFinishedChecking(h); emit metadataReceived(h); + if(torrentsToPausedAfterChecking.contains(hash)) { + torrentsToPausedAfterChecking.removeOne(hash); + h.pause(); + emit pausedTorrent(h); + } } } a = s->pop_alert(); } } + void Bittorrent::recheckTorrent(QString hash) { + QTorrentHandle h = getTorrentHandle(hash); + if(h.is_valid() && h.has_metadata()) { + if(h.is_paused()) { + if(!torrentsToPausedAfterChecking.contains(h.hash())) { + torrentsToPausedAfterChecking << h.hash(); + h.resume(); + } + } + h.force_recheck(); + } + } + QHash Bittorrent::getTrackersInfo(QString hash) const{ return trackersInfos.value(hash, QHash()); } diff --git a/src/bittorrent.h b/src/bittorrent.h index e2d1572e1..69cd539af 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -94,6 +94,7 @@ private: QPointer timerAlerts; QMap savepath_fromurl; QHash > trackersInfos; + QStringList torrentsToPausedAfterChecking; // Ratio QPointer BigRatioTimer; // HTTP @@ -180,6 +181,7 @@ public slots: void deleteTorrent(QString hash, bool delete_local_files = false); void startUpTorrents(); session_proxy asyncDeletion(); + void recheckTorrent(QString hash); /* Needed by Web UI */ void pauseAllTorrents(); void pauseTorrent(QString hash); diff --git a/src/httpconnection.cpp b/src/httpconnection.cpp index 564b49c98..9e9e92a7b 100644 --- a/src/httpconnection.cpp +++ b/src/httpconnection.cpp @@ -456,8 +456,8 @@ void HttpConnection::respondCommand(QString command) void HttpConnection::recheckTorrent(QString hash) { QTorrentHandle h = BTSession->getTorrentHandle(hash); - if(h.is_valid() && !h.is_paused()){ - h.force_recheck(); + if(h.is_valid()){ + BTSession->recheckTorrent(h.hash()); } } @@ -466,7 +466,7 @@ void HttpConnection::recheckAllTorrents() { std::vector::iterator torrentIT; for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { QTorrentHandle h = QTorrentHandle(*torrentIT); - if(h.is_valid() && !h.is_paused()) - h.force_recheck(); + if(h.is_valid()) + BTSession->recheckTorrent(h.hash()); } } diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 75dff4e59..8c3b6f5c3 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -760,8 +760,9 @@ void TransferListWidget::recheckSelectedTorrents() { foreach(const QModelIndex &index, selectedIndexes){ QString hash = getHashFromRow(mapToSource(index).row()); QTorrentHandle h = BTSession->getTorrentHandle(hash); - if(h.is_valid() && h.has_metadata()) - h.force_recheck(); + if(h.is_valid()) { + BTSession->recheckTorrent(h.hash()); + } } }