diff --git a/TODO b/TODO index 84ae3731a..9fca7e10f 100644 --- a/TODO +++ b/TODO @@ -45,13 +45,12 @@ - Keep documention up to date - Windows port (Chris - Peerkoel) - Update to Qt4.3.1 and see if everything is ok +- wait for fastresume data on exit should be in a thread? * beta5 - Translations update (IN PROGRESS) - make use of finishedChecking alert if hydri applies my patch for this - Clean up delayed progress column sorting code - Clean up pause after checking code - - Fix fast resume problems - - Test rss now that it has been rewritten - Wait for some bug fixes in libtorrent : - upload/download limit per torrent (Ticket #83) - double free or corruption on exit (Ticket #84) FIXED? @@ -71,7 +70,8 @@ LANGUAGES UPDATED: beta4->beta5 changelog: - FEATURE: Supports Bittorrent FAST extension -- BUGFIX: Wait for torrent_paused_alert before saving fast resume data +- BUGFIX: Wait for torrent_paused_alert before saving fast resume data on exit +- BUGFIX: Wait for torrent_paused_alert before reloading a torrent for full allocation mode - BUFFIG: Fixed overflow causing ratio data to be negative - BUGFIX: Fixed progress column delayed sorting (after torrent finished checking) - BUGFIX: Finished torrents were still displayed as checking when paused by libtorrent on full disk (hit an assert) diff --git a/src/GUI.cpp b/src/GUI.cpp index 2c53f9b60..067068388 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -1229,7 +1229,6 @@ void GUI::showProperties(const QModelIndex &index){ QString fileHash = DLListModel->data(DLListModel->index(row, HASH)).toString(); torrent_handle h = BTSession->getTorrentHandle(fileHash); properties *prop = new properties(this, BTSession, h); - connect(prop, SIGNAL(mustHaveFullAllocationMode(torrent_handle)), BTSession, SLOT(reloadTorrent(torrent_handle))); connect(prop, SIGNAL(filteredFilesChanged(QString)), this, SLOT(updateFileSizeAndProgress(QString))); prop->show(); } diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index a3d593acf..b8b962b0b 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -948,6 +948,9 @@ void bittorrent::readAlerts(){ torrent_handle h = p->handle; if(h.is_valid() && h.is_paused()){ pausedTorrents << hash; + if(reloadingTorrents.indexOf(hash) != -1){ + reloadTorrent(h); + } }else{ qDebug("Not adding torrent no pausedList, it is invalid or resumed"); } @@ -973,6 +976,22 @@ QList > bittorrent::getTrackersErrors(QString hash) cons return trackersErrors.value(hash, QList >()); } +// Function to reload the torrent async after the torrent is actually +// paused so that we can get fastresume data +void bittorrent::pauseAndReloadTorrent(const torrent_handle &h){ + if(!h.is_valid()){ + std::cerr << "/!\\ Error: Invalid handle\n"; + return; + } + // ask to pause the torrent (async) + h.pause(); + QString hash = QString(misc::toString(h.info_hash()).c_str()); + // Add it to reloadingTorrents list so that we now we + // we should reload the torrent once we receive the + // torrent_paused_alert. pause() is async now... + reloadingTorrents << hash; +} + // Reload a torrent with full allocation mode void bittorrent::reloadTorrent(const torrent_handle &h){ qDebug("** Reloading a torrent"); @@ -998,8 +1017,8 @@ void bittorrent::reloadTorrent(const torrent_handle &h){ torrentBackup.mkpath(torrentBackup.path()); } // Write fast resume data - // Pause download (needed before fast resume writing) - h.pause(); + // Torrent is already paused + Q_ASSERT(pausedTorrents.indexOf(fileHash) != 1); // Extracting resume data if (h.has_metadata()){ // get fast resume data @@ -1041,6 +1060,8 @@ void bittorrent::reloadTorrent(const torrent_handle &h){ } } + + int bittorrent::getListenPort() const{ return s->listen_port(); } diff --git a/src/bittorrent.h b/src/bittorrent.h index e028f8d05..474f6a0c9 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -49,6 +49,7 @@ class bittorrent : public QObject{ QString defaultSavePath; QStringList torrentsToPauseAfterChecking; QStringList torrentsUnchecked; + QStringList reloadingTorrents; QHash > ETAstats; QHash ETAs; QHash > ratioData; @@ -102,7 +103,7 @@ class bittorrent : public QObject{ void enablePeerExchange(); void enableIPFilter(ip_filter filter); void disableIPFilter(); - void reloadTorrent(const torrent_handle &h); + void pauseAndReloadTorrent(const torrent_handle &h); void setTorrentFinishedChecking(QString hash); void resumeUnfinishedTorrents(); void updateETAs(); @@ -133,6 +134,7 @@ class bittorrent : public QObject{ void processDownloadedFile(QString, QString); bool loadTrackerFile(QString hash); void saveTrackerFile(QString hash); + void reloadTorrent(const torrent_handle &h); // This is protected now, call pauseAndReloadTorrent() instead signals: void invalidTorrent(QString path); diff --git a/src/properties_imp.cpp b/src/properties_imp.cpp index c8d531989..649068a99 100644 --- a/src/properties_imp.cpp +++ b/src/properties_imp.cpp @@ -606,7 +606,7 @@ void properties::savePiecesPriorities(){ } pieces_file.close(); if(hasFilteredFiles && !BTSession->inFullAllocationMode(fileHash)){ - emit mustHaveFullAllocationMode(h); + BTSession->pauseAndReloadTorrent(h); } BTSession->loadFilesPriorities(h); emit filteredFilesChanged(fileHash); diff --git a/src/properties_imp.h b/src/properties_imp.h index 7e8ab498b..005caa32e 100644 --- a/src/properties_imp.h +++ b/src/properties_imp.h @@ -73,7 +73,6 @@ class properties : public QDialog, private Ui::properties{ signals: void filteredFilesChanged(QString fileHash); void fileSizeChanged(QString fileHash); - void mustHaveFullAllocationMode(torrent_handle h); public: // Constructor