From b6bf09fc0f948bcf458c8f27930caa2861b6c748 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Mon, 4 May 2020 11:11:24 +0300 Subject: [PATCH] Fix calculation of torrent current state Some actions can be performed despite of other states (e.g. "Errored" torrent can check its files currently) so the states that relate to such actions should override other (so-called "static") states. --- src/base/bittorrent/torrenthandleimpl.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/base/bittorrent/torrenthandleimpl.cpp b/src/base/bittorrent/torrenthandleimpl.cpp index 2508e9a9f..a6ba38cf4 100644 --- a/src/base/bittorrent/torrenthandleimpl.cpp +++ b/src/base/bittorrent/torrenthandleimpl.cpp @@ -851,15 +851,21 @@ TorrentState TorrentHandleImpl::state() const void TorrentHandleImpl::updateState() { - if (hasError()) { - m_state = TorrentState::Error; - } - else if (m_nativeStatus.state == lt::torrent_status::checking_resume_data) { + if (m_nativeStatus.state == lt::torrent_status::checking_resume_data) { m_state = TorrentState::CheckingResumeData; } + else if (m_nativeStatus.state == lt::torrent_status::checking_files) { + m_state = m_hasSeedStatus ? TorrentState::CheckingUploading : TorrentState::CheckingDownloading; + } + else if (m_nativeStatus.state == lt::torrent_status::allocating) { + m_state = TorrentState::Allocating; + } else if (isMoveInProgress()) { m_state = TorrentState::Moving; } + else if (hasError()) { + m_state = TorrentState::Error; + } else if (hasMissingFiles()) { m_state = TorrentState::MissingFiles; } @@ -878,12 +884,6 @@ void TorrentHandleImpl::updateState() else m_state = m_nativeStatus.upload_payload_rate > 0 ? TorrentState::Uploading : TorrentState::StalledUploading; break; - case lt::torrent_status::allocating: - m_state = TorrentState::Allocating; - break; - case lt::torrent_status::checking_files: - m_state = m_hasSeedStatus ? TorrentState::CheckingUploading : TorrentState::CheckingDownloading; - break; case lt::torrent_status::downloading_metadata: m_state = TorrentState::DownloadingMetadata; break;