Browse Source

- Paused torrents can now be rechecked

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
1840d1c49f
  1. 18
      src/bittorrent.cpp
  2. 2
      src/bittorrent.h
  3. 8
      src/httpconnection.cpp
  4. 5
      src/transferlistwidget.cpp

18
src/bittorrent.cpp

@ -1915,12 +1915,30 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { @@ -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<QString, TrackerInfos> Bittorrent::getTrackersInfo(QString hash) const{
return trackersInfos.value(hash, QHash<QString, TrackerInfos>());
}

2
src/bittorrent.h

@ -94,6 +94,7 @@ private: @@ -94,6 +94,7 @@ private:
QPointer<QTimer> timerAlerts;
QMap<QUrl, QString> savepath_fromurl;
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
QStringList torrentsToPausedAfterChecking;
// Ratio
QPointer<QTimer> BigRatioTimer;
// HTTP
@ -180,6 +181,7 @@ public slots: @@ -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);

8
src/httpconnection.cpp

@ -456,8 +456,8 @@ void HttpConnection::respondCommand(QString command) @@ -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() { @@ -466,7 +466,7 @@ void HttpConnection::recheckAllTorrents() {
std::vector<torrent_handle>::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());
}
}

5
src/transferlistwidget.cpp

@ -760,8 +760,9 @@ void TransferListWidget::recheckSelectedTorrents() { @@ -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());
}
}
}

Loading…
Cancel
Save