From 64ac48ee116de37f68172b3dba667e2af8f78802 Mon Sep 17 00:00:00 2001 From: thalieht Date: Sat, 9 Nov 2019 12:47:02 +0200 Subject: [PATCH] Reallow to pause checking torrents --- src/base/bittorrent/torrenthandle.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index d21658d0f..cdc770603 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -1351,30 +1351,27 @@ void TorrentHandle::toggleFirstLastPiecePriority() void TorrentHandle::pause() { - if (m_startupState != Started) return; - if (m_pauseWhenReady) return; - if (isChecking()) { - m_pauseWhenReady = true; - return; - } - if (isPaused()) return; m_nativeHandle.auto_managed(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) { + m_nativeHandle.stop_when_ready(false); + 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); }