Merge: - filters: 'enable/disable filter' didn't work
Squashed commit of the following:
commit c4c616162b66f2e89932ac44253ff6bedb8692eb
Merge: 800740da 579177fc
Author: Simon Zolin <s.zolin@adguard.com>
Date: Wed Mar 11 19:14:27 2020 +0300
Merge remote-tracking branch 'origin/master' into apply-disable-filter
commit 800740dace018dbe58abc579c06f7c494cdd1c15
Author: Simon Zolin <s.zolin@adguard.com>
Date: Wed Mar 11 18:40:38 2020 +0300
improve logic
commit 2aab4fbe658de09cd4c1d0badc178e0ce9e60251
Author: Simon Zolin <s.zolin@adguard.com>
Date: Wed Mar 11 18:23:14 2020 +0300
- filters: 'disable filter' didn't work
This commit is contained in:
@@ -185,9 +185,27 @@ func handleFilteringSetURL(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
onConfigModified()
|
||||
if (status&(statusURLChanged|statusEnabledChanged)) != 0 && fj.Data.Enabled {
|
||||
restart := false
|
||||
if (status & statusEnabledChanged) != 0 {
|
||||
// we must add or remove filter rules
|
||||
restart = true
|
||||
}
|
||||
if (status&statusUpdateRequired) != 0 && fj.Data.Enabled {
|
||||
// download new filter and apply its rules
|
||||
_, _ = refreshFilters(fj.Whitelist, true)
|
||||
flags := FilterRefreshBlocklists
|
||||
if fj.Whitelist {
|
||||
flags = FilterRefreshAllowlists
|
||||
}
|
||||
nUpdated, _ := refreshFilters(flags, true)
|
||||
// if at least 1 filter has been updated, refreshFilters() restarts the filtering automatically
|
||||
// if not - we restart the filtering ourselves
|
||||
restart = false
|
||||
if nUpdated == 0 {
|
||||
restart = true
|
||||
}
|
||||
}
|
||||
if restart {
|
||||
enableFilters(true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +244,11 @@ func handleFilteringRefresh(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
Context.controlLock.Unlock()
|
||||
resp.Updated, err = refreshFilters(req.White, false)
|
||||
flags := FilterRefreshBlocklists
|
||||
if req.White {
|
||||
flags = FilterRefreshAllowlists
|
||||
}
|
||||
resp.Updated, err = refreshFilters(flags|FilterRefreshForce, false)
|
||||
Context.controlLock.Lock()
|
||||
if err != nil {
|
||||
httpError(w, http.StatusInternalServerError, "%s", err)
|
||||
|
||||
Reference in New Issue
Block a user