mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-16 02:18:28 -07:00
- dnsfilter: fix post-install error "filter file not found"
Right after installation we don't have the filter files downloaded. While they are being downloaded, we replace them with an empty filter.
This commit is contained in:
parent
e03efbcdd1
commit
b0cfd7228e
@ -11,6 +11,7 @@ import (
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@ -525,17 +526,34 @@ func (d *Dnsfilter) lookupCommon(host string, lookupstats *LookupStats, cache gc
|
||||
// Adding rule and matching against the rules
|
||||
//
|
||||
|
||||
// Return TRUE if file exists
|
||||
func fileExists(fn string) bool {
|
||||
_, err := os.Stat(fn)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Initialize urlfilter objects
|
||||
func (d *Dnsfilter) initFiltering(filters map[int]string) error {
|
||||
listArray := []urlfilter.RuleList{}
|
||||
for id, dataOrFilePath := range filters {
|
||||
var list urlfilter.RuleList
|
||||
|
||||
if id == 0 {
|
||||
list = &urlfilter.StringRuleList{
|
||||
ID: 0,
|
||||
RulesText: dataOrFilePath,
|
||||
IgnoreCosmetic: false,
|
||||
}
|
||||
|
||||
} else if !fileExists(dataOrFilePath) {
|
||||
list = &urlfilter.StringRuleList{
|
||||
ID: id,
|
||||
IgnoreCosmetic: false,
|
||||
}
|
||||
|
||||
} else {
|
||||
var err error
|
||||
list, err = urlfilter.NewFileRuleList(id, dataOrFilePath, false)
|
||||
|
Loading…
Reference in New Issue
Block a user