Browse Source

Save fastresumes when changing torrent priorities

adaptive-webui-19844
thalieht 6 years ago
parent
commit
95b02bbb2e
  1. 20
      src/base/bittorrent/session.cpp
  2. 1
      src/base/bittorrent/session.h

20
src/base/bittorrent/session.cpp

@ -1998,6 +1998,8 @@ void Session::increaseTorrentsPriority(const QStringList &hashes)
torrentQueuePositionUp(torrent->nativeHandle()); torrentQueuePositionUp(torrent->nativeHandle());
torrentQueue.pop(); torrentQueue.pop();
} }
handleTorrentsPrioritiesChanged();
} }
void Session::decreaseTorrentsPriority(const QStringList &hashes) 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) for (auto i = m_loadedMetadata.cbegin(); i != m_loadedMetadata.cend(); ++i)
torrentQueuePositionBottom(m_nativeSession->find_torrent(i.key())); torrentQueuePositionBottom(m_nativeSession->find_torrent(i.key()));
handleTorrentsPrioritiesChanged();
} }
void Session::topTorrentsPriority(const QStringList &hashes) void Session::topTorrentsPriority(const QStringList &hashes)
@ -2043,6 +2047,8 @@ void Session::topTorrentsPriority(const QStringList &hashes)
torrentQueuePositionTop(torrent->nativeHandle()); torrentQueuePositionTop(torrent->nativeHandle());
torrentQueue.pop(); torrentQueue.pop();
} }
handleTorrentsPrioritiesChanged();
} }
void Session::bottomTorrentsPriority(const QStringList &hashes) 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) for (auto i = m_loadedMetadata.cbegin(); i != m_loadedMetadata.cend(); ++i)
torrentQueuePositionBottom(m_nativeSession->find_torrent(i.key())); torrentQueuePositionBottom(m_nativeSession->find_torrent(i.key()));
handleTorrentsPrioritiesChanged();
} }
QHash<InfoHash, TorrentHandle *> Session::torrents() const QHash<InfoHash, TorrentHandle *> Session::torrents() const
@ -3531,6 +3539,18 @@ void Session::handleTorrentShareLimitChanged(TorrentHandle *const torrent)
updateSeedingLimitTimer(); updateSeedingLimitTimer();
} }
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) void Session::saveTorrentResumeData(TorrentHandle *const torrent)
{ {
qDebug("Saving fastresume data for %s", qUtf8Printable(torrent->name())); qDebug("Saving fastresume data for %s", qUtf8Printable(torrent->name()));

1
src/base/bittorrent/session.h

@ -481,6 +481,7 @@ namespace BitTorrent
// TorrentHandle interface // TorrentHandle interface
void handleTorrentShareLimitChanged(TorrentHandle *const torrent); void handleTorrentShareLimitChanged(TorrentHandle *const torrent);
void handleTorrentsPrioritiesChanged();
void handleTorrentNameChanged(TorrentHandle *const torrent); void handleTorrentNameChanged(TorrentHandle *const torrent);
void handleTorrentSavePathChanged(TorrentHandle *const torrent); void handleTorrentSavePathChanged(TorrentHandle *const torrent);
void handleTorrentCategoryChanged(TorrentHandle *const torrent, const QString &oldCategory); void handleTorrentCategoryChanged(TorrentHandle *const torrent, const QString &oldCategory);

Loading…
Cancel
Save