From 57309c7d82978507a065c4b91ec064c29be2bbb7 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Wed, 29 Aug 2007 14:54:03 +0000 Subject: [PATCH] - Do not save paused torrents in a list anymore to save some memory --- src/bittorrent.cpp | 47 ++++++++++++++-------------------------------- src/bittorrent.h | 3 +-- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index cece6fcb2..c133ad0a8 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -186,12 +186,7 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) { trackersErrors.remove(hash); // Remove it from ratio table ratioData.remove(hash); - // Remove it from pausedTorrents list - int index = pausedTorrents.indexOf(hash); - if(index != -1) { - pausedTorrents.removeAt(index); - } - index = finishedTorrents.indexOf(hash); + int index = finishedTorrents.indexOf(hash); if(index != -1) { finishedTorrents.removeAt(index); }else{ @@ -298,12 +293,6 @@ bool bittorrent::resumeTorrent(QString hash) { torrentsToPauseAfterChecking.removeAt(index); success = true; } - // Remove it from pausedTorrents list - index = pausedTorrents.indexOf(hash); - if(index != -1) - pausedTorrents.removeAt(index); - else - qDebug("Resumed Torrent was not in paused list"); return success; } @@ -724,10 +713,6 @@ void bittorrent::saveDownloadUploadForTorrent(QString hash) { ratio_file.close(); } -bool bittorrent::receivedPausedAlert(QString hash) const{ - return (pausedTorrents.indexOf(hash) != -1); -} - // Save fastresume data for all torrents // and remove them from the session void bittorrent::saveFastResumeAndRatioData() { @@ -748,7 +733,10 @@ void bittorrent::saveFastResumeAndRatioData() { continue; } // Pause download (needed before fast resume writing) - h.pause(); + if(!h.is_paused()){ + waitingForPause << h.hash(); + h.pause(); + } } // Write fast resume data for(unsigned int i=0; i > > trackersErrors; deleteThread *deleter; - QStringList pausedTorrents; + QStringList waitingForPause; QStringList finishedTorrents; QStringList unfinishedTorrents; @@ -79,7 +79,6 @@ class bittorrent : public QObject{ float getRealRatio(QString hash) const; session* getSession() const; QList > getTrackersErrors(QString hash) const; - bool receivedPausedAlert(QString hash) const; QStringList getFinishedTorrents() const; QStringList getUnfinishedTorrents() const; bool isFinished(QString hash) const;