mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-15 01:00:17 +00:00
Save fast resume data every 3 minutes
This commit is contained in:
parent
7b8fa49482
commit
5aa348a574
@ -31,7 +31,6 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTimer>
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -132,6 +131,8 @@ Bittorrent::Bittorrent()
|
|||||||
timerAlerts = new QTimer();
|
timerAlerts = new QTimer();
|
||||||
connect(timerAlerts, SIGNAL(timeout()), this, SLOT(readAlerts()));
|
connect(timerAlerts, SIGNAL(timeout()), this, SLOT(readAlerts()));
|
||||||
timerAlerts->start(3000);
|
timerAlerts->start(3000);
|
||||||
|
connect(&resumeDataTimer, SIGNAL(timeout()), this, SLOT(saveTempFastResumeData()));
|
||||||
|
resumeDataTimer.start(180000); // 3min
|
||||||
// To download from urls
|
// To download from urls
|
||||||
downloader = new downloadThread(this);
|
downloader = new downloadThread(this);
|
||||||
connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
|
connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
|
||||||
@ -1393,10 +1394,23 @@ float Bittorrent::getRealRatio(QString hash) const{
|
|||||||
return ratio;
|
return ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bittorrent::saveTempFastResumeData() {
|
||||||
|
std::vector<torrent_handle> torrents = s->get_torrents();
|
||||||
|
std::vector<torrent_handle>::iterator torrentIT;
|
||||||
|
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
|
||||||
|
QTorrentHandle h = QTorrentHandle(*torrentIT);
|
||||||
|
if(!h.is_valid() || !h.has_metadata() || h.is_seed() || h.is_paused()) continue;
|
||||||
|
if(h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking) continue;
|
||||||
|
qDebug("Saving fastresume data for %s", qPrintable(h.name()));
|
||||||
|
h.save_resume_data();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Only save fast resume data for unfinished and unpaused torrents (Optimization)
|
// Only save fast resume data for unfinished and unpaused torrents (Optimization)
|
||||||
// Called periodically and on exit
|
// Called periodically and on exit
|
||||||
void Bittorrent::saveFastResumeData() {
|
void Bittorrent::saveFastResumeData() {
|
||||||
// Stop listening for alerts
|
// Stop listening for alerts
|
||||||
|
resumeDataTimer.stop();
|
||||||
timerAlerts->stop();
|
timerAlerts->stop();
|
||||||
int num_resume_data = 0;
|
int num_resume_data = 0;
|
||||||
// Pause session
|
// Pause session
|
||||||
@ -1985,12 +1999,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/*else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) {
|
else if (torrent_paused_alert* p = dynamic_cast<torrent_paused_alert*>(a.get())) {
|
||||||
QTorrentHandle h(p->handle);
|
p->handle.save_resume_data();
|
||||||
if(h.is_valid()) {
|
|
||||||
emit torrentPaused(h);
|
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) {
|
else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) {
|
||||||
// Level: fatal
|
// Level: fatal
|
||||||
QTorrentHandle h(p->handle);
|
QTorrentHandle h(p->handle);
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#endif
|
#endif
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <libtorrent/session.hpp>
|
#include <libtorrent/session.hpp>
|
||||||
#include <libtorrent/ip_filter.hpp>
|
#include <libtorrent/ip_filter.hpp>
|
||||||
@ -194,6 +195,7 @@ protected slots:
|
|||||||
void deleteBigRatios();
|
void deleteBigRatios();
|
||||||
void takeETASamples();
|
void takeETASamples();
|
||||||
void exportTorrentFiles(QString path);
|
void exportTorrentFiles(QString path);
|
||||||
|
void saveTempFastResumeData();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void addedTorrent(QTorrentHandle& h);
|
void addedTorrent(QTorrentHandle& h);
|
||||||
@ -222,6 +224,7 @@ private:
|
|||||||
QMap<QUrl, QString> savepath_fromurl;
|
QMap<QUrl, QString> savepath_fromurl;
|
||||||
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
|
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
|
||||||
QStringList torrentsToPausedAfterChecking;
|
QStringList torrentsToPausedAfterChecking;
|
||||||
|
QTimer resumeDataTimer;
|
||||||
// Ratio
|
// Ratio
|
||||||
QPointer<QTimer> BigRatioTimer;
|
QPointer<QTimer> BigRatioTimer;
|
||||||
// HTTP
|
// HTTP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user