diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index aebb53d54..46aa29235 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -89,6 +89,7 @@ #include "common.h" #include "customstorage.h" #include "dbresumedatastorage.h" +#include "downloadpriority.h" #include "filesearcher.h" #include "filterparserthread.h" #include "loadtorrentparams.h" @@ -2146,12 +2147,21 @@ bool Session::addTorrent_impl(const std::variant &source } Q_ASSERT(p.file_priorities.empty()); - std::transform(addTorrentParams.filePriorities.cbegin(), addTorrentParams.filePriorities.cend() - , std::back_inserter(p.file_priorities), [](const DownloadPriority priority) + if (addTorrentParams.filePriorities.empty()) { - return static_cast( + // Use qBittorrent default priority rather than libtorrent's (4) + p.file_priorities = std::vector(metadata.filesCount(), static_cast( + static_cast(DownloadPriority::Normal))); + } + else + { + std::transform(addTorrentParams.filePriorities.cbegin(), addTorrentParams.filePriorities.cend() + , std::back_inserter(p.file_priorities), [](const DownloadPriority priority) + { + return static_cast( static_cast(priority)); - }); + }); + } p.ti = metadata.nativeInfo(); } diff --git a/src/base/bittorrent/torrentimpl.cpp b/src/base/bittorrent/torrentimpl.cpp index 16670688b..d36fe9b3d 100644 --- a/src/base/bittorrent/torrentimpl.cpp +++ b/src/base/bittorrent/torrentimpl.cpp @@ -1512,6 +1512,10 @@ void TorrentImpl::endReceivedMetadataHandling(const QString &savePath, const QSt p.renamed_files[lt::file_index_t {i}] = fileNames[i].toStdString(); p.save_path = Utils::Fs::toNativePath(savePath).toStdString(); + // Use qBittorrent default priority rather than libtorrent's (4) + p.file_priorities = std::vector(fileNames.size(), static_cast( + static_cast(DownloadPriority::Normal))); + reload(); // If first/last piece priority was specified when adding this torrent,