1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-03-10 12:21:12 +00:00

Save fast resume data periodically only for torrents that need it

This commit is contained in:
Christophe Dumez 2011-04-17 14:54:47 +00:00
parent 982098a205
commit 104ebbc9a1

View File

@ -1568,6 +1568,7 @@ qreal QBtSession::getRealRatio(const QString &hash) const{
return ratio; return ratio;
} }
// Called periodically
void QBtSession::saveTempFastResumeData() { void QBtSession::saveTempFastResumeData() {
std::vector<torrent_handle> torrents = s->get_torrents(); std::vector<torrent_handle> torrents = s->get_torrents();
std::vector<torrent_handle>::iterator torrentIT; std::vector<torrent_handle>::iterator torrentIT;
@ -1575,6 +1576,9 @@ void QBtSession::saveTempFastResumeData() {
QTorrentHandle h = QTorrentHandle(*torrentIT); QTorrentHandle h = QTorrentHandle(*torrentIT);
try { try {
if(!h.is_valid() || !h.has_metadata() /*|| h.is_seed() || h.is_paused()*/) continue; if(!h.is_valid() || !h.has_metadata() /*|| h.is_seed() || h.is_paused()*/) continue;
#if LIBTORRENT_VERSION_MINOR > 15
if(!h.need_save_resume_data()) continue;
#endif
if(h.state() == torrent_status::checking_files || h.state() == torrent_status::queued_for_checking) 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())); qDebug("Saving fastresume data for %s", qPrintable(h.name()));
h.save_resume_data(); h.save_resume_data();
@ -1583,7 +1587,7 @@ void QBtSession::saveTempFastResumeData() {
} }
// 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 on exit
void QBtSession::saveFastResumeData() { void QBtSession::saveFastResumeData() {
qDebug("Saving fast resume data..."); qDebug("Saving fast resume data...");
// Stop listening for alerts // Stop listening for alerts