mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
Merge pull request #13954 from glassez/fix-stopped
Fix bug of torrents don't save "stopped" state
This commit is contained in:
commit
aed25ff87c
@ -4253,21 +4253,21 @@ bool Session::loadTorrentResumeData(const QByteArray &data, const TorrentInfo &m
|
|||||||
if (metadata.isValid())
|
if (metadata.isValid())
|
||||||
p.ti = metadata.nativeInfo();
|
p.ti = metadata.nativeInfo();
|
||||||
|
|
||||||
torrentParams.paused = (p.flags & lt::torrent_flags::paused) && !(p.flags & lt::torrent_flags::auto_managed);
|
if (p.flags & lt::torrent_flags::stop_when_ready)
|
||||||
if (!torrentParams.paused)
|
|
||||||
{
|
{
|
||||||
// If torrent has "stop_when_ready" flag set then it is actually "stopped"
|
// If torrent has "stop_when_ready" flag set then it is actually "stopped"
|
||||||
// but temporarily "resumed" to perform some service jobs (e.g. checking)
|
torrentParams.paused = true;
|
||||||
torrentParams.paused = !!(p.flags & lt::torrent_flags::stop_when_ready);
|
torrentParams.forced = false;
|
||||||
|
// ...but temporarily "resumed" to perform some service jobs (e.g. checking)
|
||||||
|
p.flags &= ~lt::torrent_flags::paused;
|
||||||
|
p.flags |= lt::torrent_flags::auto_managed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Fix inconsistent state when "paused" torrent has "stop_when_ready" flag set
|
torrentParams.paused = (p.flags & lt::torrent_flags::paused) && !(p.flags & lt::torrent_flags::auto_managed);
|
||||||
p.flags &= ~lt::torrent_flags::stop_when_ready;
|
torrentParams.forced = !(p.flags & lt::torrent_flags::paused) && !(p.flags & lt::torrent_flags::auto_managed);
|
||||||
}
|
}
|
||||||
|
|
||||||
torrentParams.forced = !(p.flags & lt::torrent_flags::paused) && !(p.flags & lt::torrent_flags::auto_managed);
|
|
||||||
|
|
||||||
const bool hasMetadata = (p.ti && p.ti->is_valid());
|
const bool hasMetadata = (p.ti && p.ti->is_valid());
|
||||||
if (!hasMetadata && !root.dict_find("info-hash"))
|
if (!hasMetadata && !root.dict_find("info-hash"))
|
||||||
{
|
{
|
||||||
|
@ -1325,6 +1325,7 @@ void TorrentHandleImpl::endReceivedMetadataHandling(const QString &savePath, con
|
|||||||
m_nativeHandle = m_nativeSession->add_torrent(p);
|
m_nativeHandle = m_nativeSession->add_torrent(p);
|
||||||
m_nativeHandle.queue_position_set(queuePos);
|
m_nativeHandle.queue_position_set(queuePos);
|
||||||
|
|
||||||
|
m_torrentInfo = TorrentInfo {m_nativeHandle.torrent_file()};
|
||||||
// If first/last piece priority was specified when adding this torrent,
|
// If first/last piece priority was specified when adding this torrent,
|
||||||
// we should apply it now that we have metadata:
|
// we should apply it now that we have metadata:
|
||||||
if (m_hasFirstLastPiecePriority)
|
if (m_hasFirstLastPiecePriority)
|
||||||
@ -1337,7 +1338,6 @@ void TorrentHandleImpl::endReceivedMetadataHandling(const QString &savePath, con
|
|||||||
m_nativeHandle.resume();
|
m_nativeHandle.resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_torrentInfo = TorrentInfo {m_nativeHandle.torrent_file()};
|
|
||||||
m_maintenanceJob = MaintenanceJob::None;
|
m_maintenanceJob = MaintenanceJob::None;
|
||||||
|
|
||||||
updateStatus();
|
updateStatus();
|
||||||
@ -1485,11 +1485,10 @@ void TorrentHandleImpl::handleTorrentCheckedAlert(const lt::torrent_checked_aler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveResumeData();
|
||||||
|
|
||||||
if (m_fastresumeDataRejected && !m_hasMissingFiles)
|
if (m_fastresumeDataRejected && !m_hasMissingFiles)
|
||||||
{
|
|
||||||
saveResumeData();
|
|
||||||
m_fastresumeDataRejected = false;
|
m_fastresumeDataRejected = false;
|
||||||
}
|
|
||||||
|
|
||||||
updateStatus();
|
updateStatus();
|
||||||
|
|
||||||
@ -1554,7 +1553,12 @@ void TorrentHandleImpl::handleSaveResumeDataAlert(const lt::save_resume_data_ale
|
|||||||
m_ltAddTorrentParams = p->params;
|
m_ltAddTorrentParams = p->params;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_isStopped)
|
if (m_isStopped)
|
||||||
|
{
|
||||||
|
m_ltAddTorrentParams.flags |= lt::torrent_flags::paused;
|
||||||
|
m_ltAddTorrentParams.flags &= ~lt::torrent_flags::auto_managed;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// Torrent can be actually "running" but temporarily "paused" to perform some
|
// Torrent can be actually "running" but temporarily "paused" to perform some
|
||||||
// service jobs behind the scenes so we need to restore it as "running"
|
// service jobs behind the scenes so we need to restore it as "running"
|
||||||
@ -1984,7 +1988,7 @@ void TorrentHandleImpl::prioritizeFiles(const QVector<DownloadPriority> &priorit
|
|||||||
if ((oldPriorities[i] == DownloadPriority::Ignored)
|
if ((oldPriorities[i] == DownloadPriority::Ignored)
|
||||||
&& (priorities[i] > DownloadPriority::Ignored)
|
&& (priorities[i] > DownloadPriority::Ignored)
|
||||||
&& (progress[i] < 1.0))
|
&& (progress[i] < 1.0))
|
||||||
{
|
{
|
||||||
m_hasSeedStatus = false;
|
m_hasSeedStatus = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user