mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-03-09 20:01:08 +00:00
- Do not save fastresume data for paused torrents anymore
This commit is contained in:
parent
f0ef21e409
commit
4f989b674f
@ -59,7 +59,7 @@ bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false
|
|||||||
connect(ETARefresher, SIGNAL(timeout()), this, SLOT(updateETAs()));
|
connect(ETARefresher, SIGNAL(timeout()), this, SLOT(updateETAs()));
|
||||||
ETARefresher->start(ETA_REFRESH_INTERVAL);
|
ETARefresher->start(ETA_REFRESH_INTERVAL);
|
||||||
fastResumeSaver = new QTimer();
|
fastResumeSaver = new QTimer();
|
||||||
connect(fastResumeSaver, SIGNAL(timeout()), this, SLOT(saveFastResumeAndRatioDataUnfinished()));
|
connect(fastResumeSaver, SIGNAL(timeout()), this, SLOT(saveFastResumeAndRatioData()));
|
||||||
fastResumeSaver->start(60000);
|
fastResumeSaver->start(60000);
|
||||||
// To download from urls
|
// To download from urls
|
||||||
downloader = new downloadThread(this);
|
downloader = new downloadThread(this);
|
||||||
@ -321,6 +321,8 @@ bool bittorrent::pauseTorrent(QString hash) {
|
|||||||
if(h.is_valid() && !h.is_paused()) {
|
if(h.is_valid() && !h.is_paused()) {
|
||||||
h.pause();
|
h.pause();
|
||||||
change = true;
|
change = true;
|
||||||
|
// Save fast resume data
|
||||||
|
saveFastResumeAndRatioData(hash);
|
||||||
qDebug("Torrent paused successfully");
|
qDebug("Torrent paused successfully");
|
||||||
}else{
|
}else{
|
||||||
if(!h.is_valid()) {
|
if(!h.is_valid()) {
|
||||||
@ -833,32 +835,19 @@ void bittorrent::saveDownloadUploadForTorrent(QString hash) {
|
|||||||
ratio_file.close();
|
ratio_file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only save fast resume data for unfinished torrents (Optimization)
|
// Only save fast resume data for unfinished and unpaused torrents (Optimization)
|
||||||
void bittorrent::saveFastResumeAndRatioDataUnfinished() {
|
// Called periodically and on exit
|
||||||
|
void bittorrent::saveFastResumeAndRatioData() {
|
||||||
QString hash;
|
QString hash;
|
||||||
QStringList hashes = getUnfinishedTorrents();
|
QStringList hashes = getUnfinishedTorrents();
|
||||||
foreach(hash, hashes) {
|
foreach(hash, hashes) {
|
||||||
saveFastResumeAndRatioData(hash);
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
}
|
if(h.is_paused()) {
|
||||||
}
|
// Do not need to save fast resume data for paused torrents
|
||||||
|
|
||||||
// Save fastresume data for all torrents (called periodically)
|
|
||||||
void bittorrent::saveFastResumeAndRatioData() {
|
|
||||||
qDebug("Saving fast resume and ratio data");
|
|
||||||
std::vector<torrent_handle> handles = s->get_torrents();
|
|
||||||
// It is not necessary to pause the torrents before saving fastresume data anymore
|
|
||||||
// because we either use Full allocation or sparse mode.
|
|
||||||
// Write fast resume data
|
|
||||||
for(unsigned int i=0; i<handles.size(); ++i) {
|
|
||||||
QTorrentHandle h = handles[i];
|
|
||||||
if(!h.is_valid()) {
|
|
||||||
qDebug("/!\\ Error: Invalid handle");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QString hash = h.hash();
|
|
||||||
saveFastResumeAndRatioData(hash);
|
saveFastResumeAndRatioData(hash);
|
||||||
}
|
}
|
||||||
qDebug("Fast resume and ratio data saved");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bittorrent::saveFastResumeAndRatioData(QString hash) {
|
void bittorrent::saveFastResumeAndRatioData(QString hash) {
|
||||||
|
@ -99,7 +99,6 @@ class bittorrent : public QObject{
|
|||||||
void preAllocateAllFiles(bool b);
|
void preAllocateAllFiles(bool b);
|
||||||
void saveFastResumeAndRatioData();
|
void saveFastResumeAndRatioData();
|
||||||
void saveFastResumeAndRatioData(QString hash);
|
void saveFastResumeAndRatioData(QString hash);
|
||||||
void saveFastResumeAndRatioDataUnfinished();
|
|
||||||
void enableDirectoryScanning(QString scan_dir);
|
void enableDirectoryScanning(QString scan_dir);
|
||||||
void disableDirectoryScanning();
|
void disableDirectoryScanning();
|
||||||
void enablePeerExchange();
|
void enablePeerExchange();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user