Browse Source

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.
adaptive-webui-19844
Vladimir Golovnev (Glassez) 5 years ago
parent
commit
b6bf09fc0f
No known key found for this signature in database
GPG Key ID: 52A2C7DEE2DFA6F7
  1. 20
      src/base/bittorrent/torrenthandleimpl.cpp

20
src/base/bittorrent/torrenthandleimpl.cpp

@ -851,15 +851,21 @@ TorrentState TorrentHandleImpl::state() const @@ -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() @@ -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;

Loading…
Cancel
Save