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.
This commit is contained in:
Vladimir Golovnev (Glassez) 2020-05-04 11:11:24 +03:00
parent 18b2511238
commit b6bf09fc0f
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7

View File

@ -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;