diff --git a/src/base/bittorrent/nativetorrentextension.cpp b/src/base/bittorrent/nativetorrentextension.cpp index 8a9d12245..6b0f8d54c 100644 --- a/src/base/bittorrent/nativetorrentextension.cpp +++ b/src/base/bittorrent/nativetorrentextension.cpp @@ -49,17 +49,6 @@ NativeTorrentExtension::NativeTorrentExtension(const lt::torrent_handle &torrent { } -// This method is called when state of torrent is changed -void NativeTorrentExtension::on_state(const lt::torrent_status::state_t state) -{ - // When a torrent enters "checking files" state while paused, we temporarily resume it - // (really we just allow libtorrent to resume it by enabling auto management for it). - if (state == lt::torrent_status::checking_files) { - if (isPaused(m_torrentHandle.status({}))) - m_torrentHandle.set_flags(lt::torrent_flags::stop_when_ready | lt::torrent_flags::auto_managed); - } -} - bool NativeTorrentExtension::on_pause() { if (!isAutoManaged(m_torrentHandle.status({}))) diff --git a/src/base/bittorrent/nativetorrentextension.h b/src/base/bittorrent/nativetorrentextension.h index 66986831e..a62bee787 100644 --- a/src/base/bittorrent/nativetorrentextension.h +++ b/src/base/bittorrent/nativetorrentextension.h @@ -37,7 +37,6 @@ public: explicit NativeTorrentExtension(const lt::torrent_handle &torrentHandle); private: - void on_state(lt::torrent_status::state_t state) override; bool on_pause() override; lt::torrent_handle m_torrentHandle; diff --git a/src/base/bittorrent/torrenthandleimpl.cpp b/src/base/bittorrent/torrenthandleimpl.cpp index 5ffa9815d..f6985de39 100644 --- a/src/base/bittorrent/torrenthandleimpl.cpp +++ b/src/base/bittorrent/torrenthandleimpl.cpp @@ -1194,6 +1194,12 @@ void TorrentHandleImpl::forceRecheck() m_nativeHandle.force_recheck(); m_unchecked = false; + + if (isPaused()) { + // When "force recheck" is applied on paused torrent, we temporarily resume it + // (really we just allow libtorrent to resume it by enabling auto management for it). + m_nativeHandle.set_flags(lt::torrent_flags::stop_when_ready | lt::torrent_flags::auto_managed); + } } void TorrentHandleImpl::setSequentialDownload(const bool enable) @@ -1449,17 +1455,6 @@ void TorrentHandleImpl::handleSaveResumeDataAlert(const lt::save_resume_data_ale m_ltAddTorrentParams.added_time = addedTime().toSecsSinceEpoch(); m_ltAddTorrentParams.save_path = Profile::instance()->toPortablePath( QString::fromStdString(m_ltAddTorrentParams.save_path)).toStdString(); - if (!m_hasMissingFiles) { - m_ltAddTorrentParams.flags = m_nativeStatus.flags; - if (m_nativeStatus.flags & lt::torrent_flags::stop_when_ready) { - // We need to redefine these values when torrent starting/rechecking - // in "paused" state since native values can be logically wrong - // (torrent can be not paused and auto_managed when it is checking). - m_ltAddTorrentParams.flags |= lt::torrent_flags::paused; - m_ltAddTorrentParams.flags &= ~lt::torrent_flags::auto_managed; - m_ltAddTorrentParams.flags &= ~lt::torrent_flags::stop_when_ready; - } - } auto resumeDataPtr = std::make_shared(lt::write_resume_data(m_ltAddTorrentParams)); lt::entry &resumeData = *resumeDataPtr;