some adblock refactors
This commit is contained in:
parent
527987b0dc
commit
e8ac98ba82
@ -326,6 +326,8 @@ QProcess* AdBlockManager::startServer(int port) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockManager::killServer() {
|
void AdBlockManager::killServer() {
|
||||||
|
m_cacheBlocks.clear();
|
||||||
|
|
||||||
if (m_serverProcess != nullptr) {
|
if (m_serverProcess != nullptr) {
|
||||||
disconnect(m_serverProcess,
|
disconnect(m_serverProcess,
|
||||||
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
||||||
@ -341,10 +343,7 @@ void AdBlockManager::killServer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdBlockManager::updateUnifiedFiltersFileAndStartServer() {
|
void AdBlockManager::updateUnifiedFilters() {
|
||||||
m_cacheBlocks.clear();
|
|
||||||
killServer();
|
|
||||||
|
|
||||||
if (QFile::exists(m_unifiedFiltersFile)) {
|
if (QFile::exists(m_unifiedFiltersFile)) {
|
||||||
QFile::remove(m_unifiedFiltersFile);
|
QFile::remove(m_unifiedFiltersFile);
|
||||||
}
|
}
|
||||||
@ -383,6 +382,11 @@ void AdBlockManager::updateUnifiedFiltersFileAndStartServer() {
|
|||||||
QDir::separator() + QSL("adblock.filters");
|
QDir::separator() + QSL("adblock.filters");
|
||||||
|
|
||||||
IOFactory::writeFile(m_unifiedFiltersFile, unified_contents.toUtf8());
|
IOFactory::writeFile(m_unifiedFiltersFile, unified_contents.toUtf8());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AdBlockManager::updateUnifiedFiltersFileAndStartServer() {
|
||||||
|
killServer();
|
||||||
|
updateUnifiedFilters();
|
||||||
|
|
||||||
if (m_enabled) {
|
if (m_enabled) {
|
||||||
auto custom_port = qApp->customAdblockPort();
|
auto custom_port = qApp->customAdblockPort();
|
||||||
|
@ -74,7 +74,9 @@ class AdBlockManager : public QObject {
|
|||||||
void onServerProcessFinished(int exit_code, QProcess::ExitStatus exit_status);
|
void onServerProcessFinished(int exit_code, QProcess::ExitStatus exit_status);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateUnifiedFilters();
|
||||||
void updateUnifiedFiltersFileAndStartServer();
|
void updateUnifiedFiltersFileAndStartServer();
|
||||||
|
|
||||||
QProcess* startServer(int port);
|
QProcess* startServer(int port);
|
||||||
void killServer();
|
void killServer();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user