mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-27 23:14:31 +00:00
parent
7faa8b7a02
commit
d1515456bc
@ -414,6 +414,7 @@ Session::Session(QObject *parent)
|
||||
, m_peerTurnoverCutoff(BITTORRENT_SESSION_KEY(u"PeerTurnoverCutOff"_qs), 90)
|
||||
, m_peerTurnoverInterval(BITTORRENT_SESSION_KEY(u"PeerTurnoverInterval"_qs), 300)
|
||||
, 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_bannedIPs(u"State/BannedIPs"_qs
|
||||
, QStringList()
|
||||
@ -467,7 +468,8 @@ Session::Session(QObject *parent)
|
||||
enqueueRefresh();
|
||||
updateSeedingLimitTimer();
|
||||
populateAdditionalTrackers();
|
||||
populateExcludedFileNamesRegExpList();
|
||||
if (isExcludedFileNamesEnabled())
|
||||
populateExcludedFileNamesRegExpList();
|
||||
|
||||
enableTracker(isTrackerEnabled());
|
||||
|
||||
@ -2256,13 +2258,16 @@ bool Session::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source
|
||||
// Use qBittorrent default priority rather than libtorrent's (4)
|
||||
p.file_priorities = std::vector(internalFilesCount, LT::toNative(DownloadPriority::Normal));
|
||||
|
||||
if (addTorrentParams.filePriorities.size() == 0)
|
||||
if (addTorrentParams.filePriorities.isEmpty())
|
||||
{
|
||||
// Check file name blacklist when priorities are not explicitly set
|
||||
for (int i = 0; i < filePaths.size(); ++i)
|
||||
if (isExcludedFileNamesEnabled())
|
||||
{
|
||||
if (isFilenameExcluded(filePaths.at(i).filename()))
|
||||
p.file_priorities[LT::toUnderlyingType(nativeIndexes[i])] = lt::dont_download;
|
||||
// Check file name blacklist when priorities are not explicitly set
|
||||
for (int i = 0; i < filePaths.size(); ++i)
|
||||
{
|
||||
if (isFilenameExcluded(filePaths.at(i).filename()))
|
||||
p.file_priorities[LT::toUnderlyingType(nativeIndexes[i])] = lt::dont_download;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -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
|
||||
{
|
||||
return m_excludedFileNames;
|
||||
@ -3122,6 +3145,9 @@ void Session::populateExcludedFileNamesRegExpList()
|
||||
|
||||
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 re.match(fileName).hasMatch();
|
||||
|
@ -455,6 +455,8 @@ namespace BitTorrent
|
||||
void setBlockPeersOnPrivilegedPorts(bool enabled);
|
||||
bool isTrackerFilteringEnabled() const;
|
||||
void setTrackerFilteringEnabled(bool enabled);
|
||||
bool isExcludedFileNamesEnabled() const;
|
||||
void setExcludedFileNamesEnabled(const bool enabled);
|
||||
QStringList excludedFileNames() const;
|
||||
void setExcludedFileNames(const QStringList &newList);
|
||||
bool isFilenameExcluded(const QString &fileName) const;
|
||||
@ -782,6 +784,7 @@ namespace BitTorrent
|
||||
CachedSettingValue<int> m_peerTurnoverCutoff;
|
||||
CachedSettingValue<int> m_peerTurnoverInterval;
|
||||
CachedSettingValue<int> m_requestQueueSize;
|
||||
CachedSettingValue<bool> m_isExcludedFileNamesEnabled;
|
||||
CachedSettingValue<QStringList> m_excludedFileNames;
|
||||
CachedSettingValue<QStringList> m_bannedIPs;
|
||||
CachedSettingValue<ResumeDataStorageType> m_resumeDataStorageType;
|
||||
|
@ -976,20 +976,23 @@ void AddNewTorrentDialog::setupTreeview()
|
||||
m_ui->contentTreeView->setExpanded(currentIndex, true);
|
||||
}
|
||||
|
||||
// Check file name blacklist for torrents that are manually added
|
||||
QVector<BitTorrent::DownloadPriority> priorities = m_contentModel->model()->getFilePriorities();
|
||||
Q_ASSERT(priorities.size() == m_torrentInfo.filesCount());
|
||||
|
||||
for (int i = 0; i < priorities.size(); ++i)
|
||||
if (BitTorrent::Session::instance()->isExcludedFileNamesEnabled())
|
||||
{
|
||||
if (priorities[i] == BitTorrent::DownloadPriority::Ignored)
|
||||
continue;
|
||||
// Check file name blacklist for torrents that are manually added
|
||||
QVector<BitTorrent::DownloadPriority> priorities = m_contentModel->model()->getFilePriorities();
|
||||
Q_ASSERT(priorities.size() == m_torrentInfo.filesCount());
|
||||
|
||||
if (BitTorrent::Session::instance()->isFilenameExcluded(m_torrentInfo.filePath(i).filename()))
|
||||
priorities[i] = BitTorrent::DownloadPriority::Ignored;
|
||||
for (int i = 0; i < priorities.size(); ++i)
|
||||
{
|
||||
if (priorities[i] == BitTorrent::DownloadPriority::Ignored)
|
||||
continue;
|
||||
|
||||
if (BitTorrent::Session::instance()->isFilenameExcluded(m_torrentInfo.filePath(i).filename()))
|
||||
priorities[i] = BitTorrent::DownloadPriority::Ignored;
|
||||
}
|
||||
|
||||
m_contentModel->model()->updateFilesPriorities(priorities);
|
||||
}
|
||||
|
||||
m_contentModel->model()->updateFilesPriorities(priorities);
|
||||
}
|
||||
|
||||
updateDiskSpaceLabel();
|
||||
|
@ -375,6 +375,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
|
||||
connect(m_ui->checkUseDownloadPath, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkUseDownloadPath, &QAbstractButton::toggled, m_ui->textDownloadPath, &QWidget::setEnabled);
|
||||
connect(m_ui->addWatchedFolderButton, &QAbstractButton::clicked, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->groupExcludedFileNames, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->textExcludedFileNames, &QPlainTextEdit::textChanged, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->removeWatchedFolderButton, &QAbstractButton::clicked, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->groupMailNotification, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
|
||||
@ -758,6 +759,7 @@ void OptionsDialog::saveOptions()
|
||||
session->setTorrentContentLayout(static_cast<BitTorrent::TorrentContentLayout>(m_ui->contentLayoutComboBox->currentIndex()));
|
||||
auto watchedFoldersModel = static_cast<WatchedFoldersModel *>(m_ui->scanFoldersView->model());
|
||||
watchedFoldersModel->apply();
|
||||
session->setExcludedFileNamesEnabled(m_ui->groupExcludedFileNames->isChecked());
|
||||
session->setExcludedFileNames(m_ui->textExcludedFileNames->toPlainText().split(u'\n', Qt::SkipEmptyParts));
|
||||
session->setTorrentExportDirectory(getTorrentExportDir());
|
||||
session->setFinishedTorrentExportDirectory(getFinishedTorrentExportDir());
|
||||
@ -1018,6 +1020,7 @@ void OptionsDialog::loadOptions()
|
||||
m_ui->checkAppendqB->setChecked(session->isAppendExtensionEnabled());
|
||||
m_ui->checkPreallocateAll->setChecked(session->isPreallocationEnabled());
|
||||
m_ui->checkRecursiveDownload->setChecked(!pref->recursiveDownloadDisabled());
|
||||
m_ui->groupExcludedFileNames->setChecked(session->isExcludedFileNamesEnabled());
|
||||
m_ui->textExcludedFileNames->setPlainText(session->excludedFileNames().join(u'\n'));
|
||||
|
||||
if (session->torrentExportDirectory().isEmpty())
|
||||
|
@ -1112,12 +1112,12 @@ Manual: Various torrent properties (e.g. save path) must be assigned manually</s
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkUseCategoryPaths">
|
||||
<property name="text">
|
||||
<string>Use Category paths in Manual Mode</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Resolve relative Save Path against appropriate Category path instead of Default one</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use Category paths in Manual Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -1266,14 +1266,13 @@ Manual: Various torrent properties (e.g. save path) must be assigned manually</s
|
||||
<property name="title">
|
||||
<string>Excluded file names</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_311">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_1">
|
||||
<property name="text">
|
||||
<string>Filters:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="textExcludedFileNames">
|
||||
<property name="toolTip">
|
||||
|
@ -141,6 +141,8 @@ void AppController::preferencesAction()
|
||||
data[u"scan_dirs"_qs] = nativeDirs;
|
||||
// === END DEPRECATED CODE === //
|
||||
|
||||
// Excluded file names
|
||||
data[u"excluded_file_names_enabled"_qs] = session->isExcludedFileNamesEnabled();
|
||||
data[u"excluded_file_names"_qs] = session->excludedFileNames().join(u'\n');
|
||||
|
||||
// Email notification upon download completion
|
||||
@ -478,6 +480,9 @@ void AppController::setPreferencesAction()
|
||||
}
|
||||
// === END DEPRECATED CODE === //
|
||||
|
||||
// Excluded file names
|
||||
if (hasKey(u"excluded_file_names_enabled"_qs))
|
||||
session->setExcludedFileNamesEnabled(it.value().toBool());
|
||||
if (hasKey(u"excluded_file_names"_qs))
|
||||
session->setExcludedFileNames(it.value().toString().split(u'\n'));
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include "base/utils/version.h"
|
||||
#include "api/isessionmanager.h"
|
||||
|
||||
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 12};
|
||||
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 13};
|
||||
|
||||
class APIController;
|
||||
class AuthController;
|
||||
|
@ -131,8 +131,10 @@
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="settings">
|
||||
<legend>QBT_TR(Excluded file names)QBT_TR[CONTEXT=OptionsDialog]</legend>
|
||||
<label for="excludedFileNamesTextarea">QBT_TR(Filters:)QBT_TR[CONTEXT=OptionsDialog]</label><br>
|
||||
<legend>
|
||||
<input type="checkbox" id="excludedFileNamesCheckbox" onclick="qBittorrent.Preferences.updateExcludedFileNamesEnabled();" />
|
||||
<label for="excludedFileNamesCheckbox">QBT_TR(Excluded file names)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</legend>
|
||||
<textarea id="excludedFileNamesTextarea" rows="6" cols="70"></textarea>
|
||||
</fieldset>
|
||||
|
||||
@ -1326,6 +1328,7 @@
|
||||
updateExportDirEnabled: updateExportDirEnabled,
|
||||
updateExportDirFinEnabled: updateExportDirFinEnabled,
|
||||
addWatchFolder: addWatchFolder,
|
||||
updateExcludedFileNamesEnabled: updateExcludedFileNamesEnabled,
|
||||
changeWatchFolderSelect: changeWatchFolderSelect,
|
||||
updateMailNotification: updateMailNotification,
|
||||
updateMailAuthSettings: updateMailAuthSettings,
|
||||
@ -1423,6 +1426,11 @@
|
||||
return folders;
|
||||
};
|
||||
|
||||
const updateExcludedFileNamesEnabled = function() {
|
||||
const isAExcludedFileNamesEnabled = $('excludedFileNamesCheckbox').getProperty('checked');
|
||||
$('excludedFileNamesTextarea').setProperty('disabled', !isAExcludedFileNamesEnabled);
|
||||
};
|
||||
|
||||
const updateExportDirEnabled = function() {
|
||||
const isExportDirEnabled = $('exportdir_checkbox').getProperty('checked');
|
||||
$('exportdir_text').setProperty('disabled', !isExportDirEnabled);
|
||||
@ -1739,6 +1747,9 @@
|
||||
addWatchFolder(folder, sel, other);
|
||||
}
|
||||
addWatchFolder();
|
||||
|
||||
// Excluded file names
|
||||
$('excludedFileNamesCheckbox').setProperty('checked', pref.excluded_file_names_enabled);
|
||||
$('excludedFileNamesTextarea').setProperty('value', pref.excluded_file_names);
|
||||
|
||||
// Email notification upon download completion
|
||||
@ -2060,6 +2071,9 @@
|
||||
|
||||
// Automatically add torrents from
|
||||
settings.set('scan_dirs', getWatchedFolders());
|
||||
|
||||
// Excluded file names
|
||||
settings.set('excluded_file_names_enabled', $('excludedFileNamesCheckbox').getProperty('checked'));
|
||||
settings.set('excluded_file_names', $('excludedFileNamesTextarea').getProperty('value'));
|
||||
|
||||
// Email notification upon download completion
|
||||
|
Loading…
x
Reference in New Issue
Block a user