|
|
@ -414,6 +414,7 @@ Session::Session(QObject *parent) |
|
|
|
, m_peerTurnoverCutoff(BITTORRENT_SESSION_KEY(u"PeerTurnoverCutOff"_qs), 90) |
|
|
|
, m_peerTurnoverCutoff(BITTORRENT_SESSION_KEY(u"PeerTurnoverCutOff"_qs), 90) |
|
|
|
, m_peerTurnoverInterval(BITTORRENT_SESSION_KEY(u"PeerTurnoverInterval"_qs), 300) |
|
|
|
, m_peerTurnoverInterval(BITTORRENT_SESSION_KEY(u"PeerTurnoverInterval"_qs), 300) |
|
|
|
, m_requestQueueSize(BITTORRENT_SESSION_KEY(u"RequestQueueSize"_qs), 500) |
|
|
|
, m_requestQueueSize(BITTORRENT_SESSION_KEY(u"RequestQueueSize"_qs), 500) |
|
|
|
|
|
|
|
, m_isExcludedFileNamesEnabled(BITTORRENT_KEY(u"ExcludedFileNamesEnabled"_qs), false) |
|
|
|
, m_excludedFileNames(BITTORRENT_SESSION_KEY(u"ExcludedFileNames"_qs)) |
|
|
|
, m_excludedFileNames(BITTORRENT_SESSION_KEY(u"ExcludedFileNames"_qs)) |
|
|
|
, m_bannedIPs(u"State/BannedIPs"_qs |
|
|
|
, m_bannedIPs(u"State/BannedIPs"_qs |
|
|
|
, QStringList() |
|
|
|
, QStringList() |
|
|
@ -467,6 +468,7 @@ Session::Session(QObject *parent) |
|
|
|
enqueueRefresh(); |
|
|
|
enqueueRefresh(); |
|
|
|
updateSeedingLimitTimer(); |
|
|
|
updateSeedingLimitTimer(); |
|
|
|
populateAdditionalTrackers(); |
|
|
|
populateAdditionalTrackers(); |
|
|
|
|
|
|
|
if (isExcludedFileNamesEnabled()) |
|
|
|
populateExcludedFileNamesRegExpList(); |
|
|
|
populateExcludedFileNamesRegExpList(); |
|
|
|
|
|
|
|
|
|
|
|
enableTracker(isTrackerEnabled()); |
|
|
|
enableTracker(isTrackerEnabled()); |
|
|
@ -2256,7 +2258,9 @@ bool Session::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source |
|
|
|
// 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)); |
|
|
|
|
|
|
|
|
|
|
|
if (addTorrentParams.filePriorities.size() == 0) |
|
|
|
if (addTorrentParams.filePriorities.isEmpty()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (isExcludedFileNamesEnabled()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Check file name blacklist when priorities are not explicitly set
|
|
|
|
// Check file name blacklist when priorities are not explicitly set
|
|
|
|
for (int i = 0; i < filePaths.size(); ++i) |
|
|
|
for (int i = 0; i < filePaths.size(); ++i) |
|
|
@ -2265,6 +2269,7 @@ bool Session::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source |
|
|
|
p.file_priorities[LT::toUnderlyingType(nativeIndexes[i])] = lt::dont_download; |
|
|
|
p.file_priorities[LT::toUnderlyingType(nativeIndexes[i])] = lt::dont_download; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
for (int i = 0; i < addTorrentParams.filePriorities.size(); ++i) |
|
|
|
for (int i = 0; i < addTorrentParams.filePriorities.size(); ++i) |
|
|
@ -3091,6 +3096,24 @@ void Session::setIPFilterFile(const Path &path) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Session::isExcludedFileNamesEnabled() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return m_isExcludedFileNamesEnabled; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Session::setExcludedFileNamesEnabled(const bool enabled) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (m_isExcludedFileNamesEnabled == enabled) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_isExcludedFileNamesEnabled = enabled; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (enabled) |
|
|
|
|
|
|
|
populateExcludedFileNamesRegExpList(); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
m_excludedFileNamesRegExpList.clear(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QStringList Session::excludedFileNames() const |
|
|
|
QStringList Session::excludedFileNames() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return m_excludedFileNames; |
|
|
|
return m_excludedFileNames; |
|
|
@ -3122,6 +3145,9 @@ void Session::populateExcludedFileNamesRegExpList() |
|
|
|
|
|
|
|
|
|
|
|
bool Session::isFilenameExcluded(const QString &fileName) const |
|
|
|
bool Session::isFilenameExcluded(const QString &fileName) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!isExcludedFileNamesEnabled()) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
return std::any_of(m_excludedFileNamesRegExpList.begin(), m_excludedFileNamesRegExpList.end(), [&fileName](const QRegularExpression &re) |
|
|
|
return std::any_of(m_excludedFileNamesRegExpList.begin(), m_excludedFileNamesRegExpList.end(), [&fileName](const QRegularExpression &re) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return re.match(fileName).hasMatch(); |
|
|
|
return re.match(fileName).hasMatch(); |
|
|
|