From 338e89176dcd60200343a294b1d0c10c40ab7cd2 Mon Sep 17 00:00:00 2001 From: Vladimir Golovnev Date: Tue, 10 May 2022 15:29:46 +0300 Subject: [PATCH] Mark all files as complete if torrent is in "seed mode" Fixes regression of bcfa486. Closes #16999. PR #17008. --- src/base/bittorrent/torrentimpl.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index dfd1834f1..0e4abc142 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -287,11 +287,12 @@ TorrentImpl::TorrentImpl(Session *session, lt::session *nativeSession m_filePaths.reserve(filesCount); m_indexMap.reserve(filesCount); m_filePriorities.reserve(filesCount); - m_completedFiles.resize(filesCount); const std::vector filePriorities = resized(m_ltAddTorrentParams.file_priorities, m_ltAddTorrentParams.ti->num_files() , LT::toNative(m_ltAddTorrentParams.file_priorities.empty() ? DownloadPriority::Normal : DownloadPriority::Ignored)); + m_completedFiles.fill(static_cast(m_ltAddTorrentParams.flags & lt::torrent_flags::seed_mode), filesCount); + for (int i = 0; i < filesCount; ++i) { const lt::file_index_t nativeIndex = m_torrentInfo.nativeIndexes().at(i); @@ -1531,11 +1532,13 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi const std::shared_ptr metadata = std::const_pointer_cast(nativeTorrentInfo()); m_torrentInfo = TorrentInfo(*metadata); m_filePriorities.reserve(filesCount()); - m_completedFiles.resize(filesCount()); const auto nativeIndexes = m_torrentInfo.nativeIndexes(); const std::vector filePriorities = resized(p.file_priorities, metadata->files().num_files() , LT::toNative(p.file_priorities.empty() ? DownloadPriority::Normal : DownloadPriority::Ignored)); + + m_completedFiles.fill(static_cast(p.flags & lt::torrent_flags::seed_mode), filesCount()); + for (int i = 0; i < fileNames.size(); ++i) { const auto nativeIndex = nativeIndexes.at(i);