Add ability to pause/resume entire BitTorrent session

PR #20757.
Closes #18993.
This commit is contained in:
Vladimir Golovnev
2024-05-03 09:02:50 +03:00
committed by GitHub
parent 05416458db
commit 8ef7d3ec9a
16 changed files with 189 additions and 114 deletions

View File

@@ -999,6 +999,9 @@ bool TorrentImpl::isStopped() const
bool TorrentImpl::isQueued() const
{
if (!m_session->isQueueingSystemEnabled())
return false;
// Torrent is Queued if it isn't in Stopped state but paused internally
return (!isStopped()
&& (m_nativeStatus.flags & lt::torrent_flags::auto_managed)
@@ -1153,7 +1156,7 @@ void TorrentImpl::updateState()
{
if (isStopped())
m_state = TorrentState::StoppedDownloading;
else if (m_session->isQueueingSystemEnabled() && isQueued())
else if (isQueued())
m_state = TorrentState::QueuedDownloading;
else
m_state = isForced() ? TorrentState::ForcedDownloadingMetadata : TorrentState::DownloadingMetadata;
@@ -1167,7 +1170,7 @@ void TorrentImpl::updateState()
{
if (isStopped())
m_state = TorrentState::StoppedUploading;
else if (m_session->isQueueingSystemEnabled() && isQueued())
else if (isQueued())
m_state = TorrentState::QueuedUploading;
else if (isForced())
m_state = TorrentState::ForcedUploading;
@@ -1180,7 +1183,7 @@ void TorrentImpl::updateState()
{
if (isStopped())
m_state = TorrentState::StoppedDownloading;
else if (m_session->isQueueingSystemEnabled() && isQueued())
else if (isQueued())
m_state = TorrentState::QueuedDownloading;
else if (isForced())
m_state = TorrentState::ForcedDownloading;
@@ -1963,6 +1966,11 @@ void TorrentImpl::handleStateUpdate(const lt::torrent_status &nativeStatus)
updateStatus(nativeStatus);
}
void TorrentImpl::handleQueueingModeChanged()
{
updateState();
}
void TorrentImpl::handleMoveStorageJobFinished(const Path &path, const MoveStorageContext context, const bool hasOutstandingJob)
{
if (context == MoveStorageContext::ChangeSavePath)