mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-23 09:49:52 +00:00
Correctly apply filename filter when !qB extension is enabled
PR #21628. Closes #21624.
This commit is contained in:
parent
5a0914e333
commit
4805afc1a2
@ -2817,6 +2817,19 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
|||||||
loadTorrentParams.name = contentName;
|
loadTorrentParams.name = contentName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto nativeIndexes = torrentInfo.nativeIndexes();
|
||||||
|
|
||||||
|
Q_ASSERT(p.file_priorities.empty());
|
||||||
|
Q_ASSERT(addTorrentParams.filePriorities.isEmpty() || (addTorrentParams.filePriorities.size() == nativeIndexes.size()));
|
||||||
|
QList<DownloadPriority> filePriorities = addTorrentParams.filePriorities;
|
||||||
|
|
||||||
|
// Filename filter should be applied before `findIncompleteFiles()` is called.
|
||||||
|
if (filePriorities.isEmpty() && isExcludedFileNamesEnabled())
|
||||||
|
{
|
||||||
|
// Check file name blacklist when priorities are not explicitly set
|
||||||
|
applyFilenameFilter(filePaths, filePriorities);
|
||||||
|
}
|
||||||
|
|
||||||
if (!loadTorrentParams.hasFinishedStatus)
|
if (!loadTorrentParams.hasFinishedStatus)
|
||||||
{
|
{
|
||||||
const Path actualDownloadPath = useAutoTMM
|
const Path actualDownloadPath = useAutoTMM
|
||||||
@ -2825,24 +2838,12 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
|||||||
isFindingIncompleteFiles = true;
|
isFindingIncompleteFiles = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto nativeIndexes = torrentInfo.nativeIndexes();
|
|
||||||
if (!isFindingIncompleteFiles)
|
if (!isFindingIncompleteFiles)
|
||||||
{
|
{
|
||||||
for (int index = 0; index < filePaths.size(); ++index)
|
for (int index = 0; index < filePaths.size(); ++index)
|
||||||
p.renamed_files[nativeIndexes[index]] = filePaths.at(index).toString().toStdString();
|
p.renamed_files[nativeIndexes[index]] = filePaths.at(index).toString().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_ASSERT(p.file_priorities.empty());
|
|
||||||
Q_ASSERT(addTorrentParams.filePriorities.isEmpty() || (addTorrentParams.filePriorities.size() == nativeIndexes.size()));
|
|
||||||
|
|
||||||
QList<DownloadPriority> filePriorities = addTorrentParams.filePriorities;
|
|
||||||
|
|
||||||
if (filePriorities.isEmpty() && isExcludedFileNamesEnabled())
|
|
||||||
{
|
|
||||||
// Check file name blacklist when priorities are not explicitly set
|
|
||||||
applyFilenameFilter(filePaths, filePriorities);
|
|
||||||
}
|
|
||||||
|
|
||||||
const int internalFilesCount = torrentInfo.nativeInfo()->files().num_files(); // including .pad files
|
const int internalFilesCount = torrentInfo.nativeInfo()->files().num_files(); // including .pad files
|
||||||
// Use qBittorrent default priority rather than libtorrent's (4)
|
// Use qBittorrent default priority rather than libtorrent's (4)
|
||||||
p.file_priorities = std::vector(internalFilesCount, LT::toNative(DownloadPriority::Normal));
|
p.file_priorities = std::vector(internalFilesCount, LT::toNative(DownloadPriority::Normal));
|
||||||
|
@ -1829,7 +1829,7 @@ void TorrentImpl::endReceivedMetadataHandling(const Path &savePath, const PathLi
|
|||||||
m_filePriorities.append(LT::fromNative(p.file_priorities[LT::toUnderlyingType(nativeIndex)]));
|
m_filePriorities.append(LT::fromNative(p.file_priorities[LT::toUnderlyingType(nativeIndex)]));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_session->applyFilenameFilter(fileNames, m_filePriorities);
|
m_session->applyFilenameFilter(m_filePaths, m_filePriorities);
|
||||||
for (int i = 0; i < m_filePriorities.size(); ++i)
|
for (int i = 0; i < m_filePriorities.size(); ++i)
|
||||||
p.file_priorities[LT::toUnderlyingType(nativeIndexes[i])] = LT::toNative(m_filePriorities[i]);
|
p.file_priorities[LT::toUnderlyingType(nativeIndexes[i])] = LT::toNative(m_filePriorities[i]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user