Skip to content

Commit

Permalink
Merge pull request #11354 from thalieht/pausechecking
Browse files Browse the repository at this point in the history
Reallow to pause checking torrents
  • Loading branch information
Chocobo1 committed Nov 9, 2019
2 parents 6a6c05f + f150b30 commit d12468f
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/base/bittorrent/torrenthandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1497,30 +1497,31 @@ void TorrentHandle::toggleFirstLastPiecePriority()

void TorrentHandle::pause()
{
if (m_startupState != Started) return;
if (m_pauseWhenReady) return;
if (isChecking()) {
m_pauseWhenReady = true;
return;
}

if (isPaused()) return;

setAutoManaged(false);
m_nativeHandle.pause();

// Libtorrent doesn't emit a torrent_paused_alert when the
// torrent is queued (no I/O)
// We test on the cached m_nativeStatus
if (isQueued())
m_session->handleTorrentPaused(this);
if (m_startupState == Started) {
if (m_pauseWhenReady) {
#if (LIBTORRENT_VERSION_NUM < 10200)
m_nativeHandle.stop_when_ready(false);
#else
m_nativeHandle.unset_flags(lt::torrent_flags::stop_when_ready);
#endif
m_pauseWhenReady = false;
}

// Libtorrent doesn't emit a torrent_paused_alert when the
// torrent is queued (no I/O)
// We test on the cached m_nativeStatus
if (isQueued())
m_session->handleTorrentPaused(this);
}
}

void TorrentHandle::resume(bool forced)
{
if (m_startupState != Started) return;

m_pauseWhenReady = false;
resume_impl(forced);
}

Expand Down

0 comments on commit d12468f

Please sign in to comment.