From f150b3077d8d202d400ee3b04341719539b4b198 Mon Sep 17 00:00:00 2001 From: thalieht Date: Thu, 10 Oct 2019 13:18:40 +0300 Subject: [PATCH] Reallow to pause checking torrents --- src/base/bittorrent/torrenthandle.cpp | 31 ++++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 5ad0565ab..0196b7949 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -1483,30 +1483,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); }