Browse Source

Preserve "skip hash check" when there is no metadata

When torrent is added without metadata libtorrent doesn't honor "seed mode" and doesn't save it in resume data so when metadata is available torrent will still check file hashes. This patch will add a logic that preserves originally enabled "seed mode" until the metadata is received.
PR #17009.
adaptive-webui-19844
Vladimir Golovnev 3 years ago committed by GitHub
parent
commit
5af78ad2cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/base/bittorrent/torrentimpl.cpp

6
src/base/bittorrent/torrentimpl.cpp

@ -1793,7 +1793,10 @@ void TorrentImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p) @@ -1793,7 +1793,10 @@ void TorrentImpl::handleSaveResumeDataAlert(const lt::save_resume_data_alert *p)
{
Q_ASSERT(m_indexMap.isEmpty());
const auto isSeedMode = static_cast<bool>(m_ltAddTorrentParams.flags & lt::torrent_flags::seed_mode);
m_ltAddTorrentParams = p->params;
if (isSeedMode)
m_ltAddTorrentParams.flags |= lt::torrent_flags::seed_mode;
m_ltAddTorrentParams.have_pieces.clear();
m_ltAddTorrentParams.verified_pieces.clear();
@ -1852,8 +1855,11 @@ void TorrentImpl::prepareResumeData(const lt::add_torrent_params &params) @@ -1852,8 +1855,11 @@ void TorrentImpl::prepareResumeData(const lt::add_torrent_params &params)
}
else
{
const bool preserveSeedMode = (!hasMetadata() && (m_ltAddTorrentParams.flags & lt::torrent_flags::seed_mode));
// Update recent resume data
m_ltAddTorrentParams = params;
if (preserveSeedMode)
m_ltAddTorrentParams.flags |= lt::torrent_flags::seed_mode;
}
// We shouldn't save upload_mode flag to allow torrent operate normally on next run

Loading…
Cancel
Save