mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-23 09:47:08 +03:00
Merge pull request #9390 from thalieht/fixprioritysaving
Save fastresumes when changing torrent priorities
This commit is contained in:
commit
af6c5ae5bd
4 changed files with 32 additions and 11 deletions
|
@ -1998,6 +1998,8 @@ void Session::increaseTorrentsPriority(const QStringList &hashes)
|
|||
torrentQueuePositionUp(torrent->nativeHandle());
|
||||
torrentQueue.pop();
|
||||
}
|
||||
|
||||
handleTorrentsPrioritiesChanged();
|
||||
}
|
||||
|
||||
void Session::decreaseTorrentsPriority(const QStringList &hashes)
|
||||
|
@ -2022,6 +2024,8 @@ void Session::decreaseTorrentsPriority(const QStringList &hashes)
|
|||
|
||||
for (auto i = m_loadedMetadata.cbegin(); i != m_loadedMetadata.cend(); ++i)
|
||||
torrentQueuePositionBottom(m_nativeSession->find_torrent(i.key()));
|
||||
|
||||
handleTorrentsPrioritiesChanged();
|
||||
}
|
||||
|
||||
void Session::topTorrentsPriority(const QStringList &hashes)
|
||||
|
@ -2043,6 +2047,8 @@ void Session::topTorrentsPriority(const QStringList &hashes)
|
|||
torrentQueuePositionTop(torrent->nativeHandle());
|
||||
torrentQueue.pop();
|
||||
}
|
||||
|
||||
handleTorrentsPrioritiesChanged();
|
||||
}
|
||||
|
||||
void Session::bottomTorrentsPriority(const QStringList &hashes)
|
||||
|
@ -2067,6 +2073,8 @@ void Session::bottomTorrentsPriority(const QStringList &hashes)
|
|||
|
||||
for (auto i = m_loadedMetadata.cbegin(); i != m_loadedMetadata.cend(); ++i)
|
||||
torrentQueuePositionBottom(m_nativeSession->find_torrent(i.key()));
|
||||
|
||||
handleTorrentsPrioritiesChanged();
|
||||
}
|
||||
|
||||
QHash<InfoHash, TorrentHandle *> Session::torrents() const
|
||||
|
@ -2360,7 +2368,7 @@ void Session::generateResumeData(bool final)
|
|||
if (!final && !torrent->needSaveResumeData()) continue;
|
||||
if (torrent->hasMissingFiles() || torrent->hasError()) continue;
|
||||
|
||||
saveTorrentResumeData(torrent, final);
|
||||
saveTorrentResumeData(torrent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3531,10 +3539,22 @@ void Session::handleTorrentShareLimitChanged(TorrentHandle *const torrent)
|
|||
updateSeedingLimitTimer();
|
||||
}
|
||||
|
||||
void Session::saveTorrentResumeData(TorrentHandle *const torrent, bool finalSave)
|
||||
void Session::handleTorrentsPrioritiesChanged()
|
||||
{
|
||||
// Save fastresume for the torrents that changed queue position
|
||||
for (TorrentHandle *const torrent : torrents()) {
|
||||
if (!torrent->isSeed()) {
|
||||
// cached vs actual queue position, qBt starts queue at 1
|
||||
if (torrent->queuePosition() != (torrent->nativeHandle().queue_position() + 1))
|
||||
saveTorrentResumeData(torrent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Session::saveTorrentResumeData(TorrentHandle *const torrent)
|
||||
{
|
||||
qDebug("Saving fastresume data for %s", qUtf8Printable(torrent->name()));
|
||||
torrent->saveResumeData(finalSave);
|
||||
torrent->saveResumeData();
|
||||
++m_numResumeData;
|
||||
}
|
||||
|
||||
|
@ -3653,8 +3673,11 @@ void Session::handleTorrentChecked(TorrentHandle *const torrent)
|
|||
|
||||
void Session::handleTorrentFinished(TorrentHandle *const torrent)
|
||||
{
|
||||
if (!torrent->hasError() && !torrent->hasMissingFiles())
|
||||
if (!torrent->hasError() && !torrent->hasMissingFiles()) {
|
||||
saveTorrentResumeData(torrent);
|
||||
if (isQueueingSystemEnabled())
|
||||
handleTorrentsPrioritiesChanged();
|
||||
}
|
||||
emit torrentFinished(torrent);
|
||||
|
||||
qDebug("Checking if the torrent contains torrent files to download");
|
||||
|
|
|
@ -481,6 +481,7 @@ namespace BitTorrent
|
|||
|
||||
// TorrentHandle interface
|
||||
void handleTorrentShareLimitChanged(TorrentHandle *const torrent);
|
||||
void handleTorrentsPrioritiesChanged();
|
||||
void handleTorrentNameChanged(TorrentHandle *const torrent);
|
||||
void handleTorrentSavePathChanged(TorrentHandle *const torrent);
|
||||
void handleTorrentCategoryChanged(TorrentHandle *const torrent, const QString &oldCategory);
|
||||
|
@ -606,7 +607,7 @@ namespace BitTorrent
|
|||
|
||||
void updateSeedingLimitTimer();
|
||||
void exportTorrentFile(TorrentHandle *const torrent, TorrentExportFolder folder = TorrentExportFolder::Regular);
|
||||
void saveTorrentResumeData(TorrentHandle *const torrent, bool finalSave = false);
|
||||
void saveTorrentResumeData(TorrentHandle *const torrent);
|
||||
|
||||
void handleAlert(libtorrent::alert *a);
|
||||
void dispatchTorrentAlert(libtorrent::alert *a);
|
||||
|
|
|
@ -504,11 +504,8 @@ bool TorrentHandle::needSaveResumeData() const
|
|||
return m_nativeHandle.need_save_resume_data();
|
||||
}
|
||||
|
||||
void TorrentHandle::saveResumeData(bool updateStatus)
|
||||
void TorrentHandle::saveResumeData()
|
||||
{
|
||||
if (updateStatus) // to update queue_position, see discussion in PR #6154
|
||||
this->updateStatus();
|
||||
|
||||
m_nativeHandle.save_resume_data();
|
||||
}
|
||||
|
||||
|
@ -1646,7 +1643,7 @@ void TorrentHandle::handleSaveResumeDataAlert(const libtorrent::save_resume_data
|
|||
resumeData["qBt-name"] = m_name.toStdString();
|
||||
resumeData["qBt-seedStatus"] = m_hasSeedStatus;
|
||||
resumeData["qBt-tempPathDisabled"] = m_tempPathDisabled;
|
||||
resumeData["qBt-queuePosition"] = queuePosition();
|
||||
resumeData["qBt-queuePosition"] = (nativeHandle().queue_position() + 1); // qBt starts queue at 1
|
||||
resumeData["qBt-hasRootFolder"] = m_hasRootFolder;
|
||||
|
||||
m_session->handleTorrentResumeDataReady(this, resumeData);
|
||||
|
|
|
@ -372,7 +372,7 @@ namespace BitTorrent
|
|||
void handleTempPathChanged();
|
||||
void handleCategorySavePathChanged();
|
||||
void handleAppendExtensionToggled();
|
||||
void saveResumeData(bool updateStatus = false);
|
||||
void saveResumeData();
|
||||
|
||||
/**
|
||||
* @brief fraction of file pieces that are available at least from one peer
|
||||
|
|
Loading…
Reference in a new issue