mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 05:27:15 +03:00
- Do not save paused torrents in a list anymore to save some memory
This commit is contained in:
parent
27e76962d1
commit
57309c7d82
2 changed files with 15 additions and 35 deletions
|
@ -186,12 +186,7 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) {
|
||||||
trackersErrors.remove(hash);
|
trackersErrors.remove(hash);
|
||||||
// Remove it from ratio table
|
// Remove it from ratio table
|
||||||
ratioData.remove(hash);
|
ratioData.remove(hash);
|
||||||
// Remove it from pausedTorrents list
|
int index = finishedTorrents.indexOf(hash);
|
||||||
int index = pausedTorrents.indexOf(hash);
|
|
||||||
if(index != -1) {
|
|
||||||
pausedTorrents.removeAt(index);
|
|
||||||
}
|
|
||||||
index = finishedTorrents.indexOf(hash);
|
|
||||||
if(index != -1) {
|
if(index != -1) {
|
||||||
finishedTorrents.removeAt(index);
|
finishedTorrents.removeAt(index);
|
||||||
}else{
|
}else{
|
||||||
|
@ -298,12 +293,6 @@ bool bittorrent::resumeTorrent(QString hash) {
|
||||||
torrentsToPauseAfterChecking.removeAt(index);
|
torrentsToPauseAfterChecking.removeAt(index);
|
||||||
success = true;
|
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;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,10 +713,6 @@ void bittorrent::saveDownloadUploadForTorrent(QString hash) {
|
||||||
ratio_file.close();
|
ratio_file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bittorrent::receivedPausedAlert(QString hash) const{
|
|
||||||
return (pausedTorrents.indexOf(hash) != -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save fastresume data for all torrents
|
// Save fastresume data for all torrents
|
||||||
// and remove them from the session
|
// and remove them from the session
|
||||||
void bittorrent::saveFastResumeAndRatioData() {
|
void bittorrent::saveFastResumeAndRatioData() {
|
||||||
|
@ -748,7 +733,10 @@ void bittorrent::saveFastResumeAndRatioData() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Pause download (needed before fast resume writing)
|
// Pause download (needed before fast resume writing)
|
||||||
h.pause();
|
if(!h.is_paused()){
|
||||||
|
waitingForPause << h.hash();
|
||||||
|
h.pause();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Write fast resume data
|
// Write fast resume data
|
||||||
for(unsigned int i=0; i<handles.size(); ++i) {
|
for(unsigned int i=0; i<handles.size(); ++i) {
|
||||||
|
@ -758,9 +746,8 @@ void bittorrent::saveFastResumeAndRatioData() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QString hash = h.hash();
|
QString hash = h.hash();
|
||||||
while(!receivedPausedAlert(hash)) {
|
while(waitingForPause.contains(hash)) {
|
||||||
//qDebug("Sleeping while waiting that %s is paused", misc::toString(h.info_hash()).c_str());
|
//qDebug("Sleeping while waiting that %s is paused", misc::toString(h.info_hash()).c_str());
|
||||||
//printPausedTorrents();
|
|
||||||
SleeperThread::msleep(300);
|
SleeperThread::msleep(300);
|
||||||
readAlerts();
|
readAlerts();
|
||||||
}
|
}
|
||||||
|
@ -1020,17 +1007,14 @@ void bittorrent::readAlerts() {
|
||||||
if(h.is_valid()){
|
if(h.is_valid()){
|
||||||
QString hash = h.hash();
|
QString hash = h.hash();
|
||||||
qDebug("Received torrent_paused_alert for %s", hash.toUtf8().data());
|
qDebug("Received torrent_paused_alert for %s", hash.toUtf8().data());
|
||||||
if(!pausedTorrents.contains(hash)) {
|
int index = waitingForPause.indexOf(hash);
|
||||||
if(h.is_valid() && h.is_paused()) {
|
if(index != -1){
|
||||||
pausedTorrents << hash;
|
waitingForPause.removeAt(index);
|
||||||
if(reloadingTorrents.indexOf(hash) != -1) {
|
}
|
||||||
reloadTorrent(h);
|
index = reloadingTorrents.indexOf(hash);
|
||||||
}
|
if(index != -1) {
|
||||||
}else{
|
reloadingTorrents.removeAt(index);
|
||||||
qDebug("Not adding torrent no pausedList, it is invalid or resumed");
|
reloadTorrent(h);
|
||||||
}
|
|
||||||
}else{
|
|
||||||
qDebug("Received alert for already paused torrent");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1108,9 +1092,6 @@ void bittorrent::reloadTorrent(const QTorrentHandle &h) {
|
||||||
if(! torrentBackup.exists()) {
|
if(! torrentBackup.exists()) {
|
||||||
torrentBackup.mkpath(torrentBackup.path());
|
torrentBackup.mkpath(torrentBackup.path());
|
||||||
}
|
}
|
||||||
// Write fast resume data
|
|
||||||
// Torrent is already paused
|
|
||||||
Q_ASSERT(pausedTorrents.indexOf(hash) != -1);
|
|
||||||
// Extracting resume data
|
// Extracting resume data
|
||||||
if (h.has_metadata()) {
|
if (h.has_metadata()) {
|
||||||
// get fast resume data
|
// get fast resume data
|
||||||
|
|
|
@ -55,7 +55,7 @@ class bittorrent : public QObject{
|
||||||
QTimer *ETARefresher;
|
QTimer *ETARefresher;
|
||||||
QHash<QString, QList<QPair<QString, QString> > > trackersErrors;
|
QHash<QString, QList<QPair<QString, QString> > > trackersErrors;
|
||||||
deleteThread *deleter;
|
deleteThread *deleter;
|
||||||
QStringList pausedTorrents;
|
QStringList waitingForPause;
|
||||||
QStringList finishedTorrents;
|
QStringList finishedTorrents;
|
||||||
QStringList unfinishedTorrents;
|
QStringList unfinishedTorrents;
|
||||||
|
|
||||||
|
@ -79,7 +79,6 @@ class bittorrent : public QObject{
|
||||||
float getRealRatio(QString hash) const;
|
float getRealRatio(QString hash) const;
|
||||||
session* getSession() const;
|
session* getSession() const;
|
||||||
QList<QPair<QString, QString> > getTrackersErrors(QString hash) const;
|
QList<QPair<QString, QString> > getTrackersErrors(QString hash) const;
|
||||||
bool receivedPausedAlert(QString hash) const;
|
|
||||||
QStringList getFinishedTorrents() const;
|
QStringList getFinishedTorrents() const;
|
||||||
QStringList getUnfinishedTorrents() const;
|
QStringList getUnfinishedTorrents() const;
|
||||||
bool isFinished(QString hash) const;
|
bool isFinished(QString hash) const;
|
||||||
|
|
Loading…
Reference in a new issue