Pull request: home: rm var shadowing, vol. 4
Closes #2803.
Squashed commit of the following:
commit cb36cc8811160bb39a32fb8eddf962d0ebe9035a
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Fri Mar 12 14:21:46 2021 +0300
home: imp more
commit 9ea7ccec8bb293881cf724d7ad57e6744243d8b9
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Fri Mar 12 13:58:10 2021 +0300
all: imp naming, refactor http srv shutdown
commit f29221007c16fd3e7230bf2c1ac37b365f3e29aa
Merge: 2247c05b bfbf73f3
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Fri Mar 12 13:35:17 2021 +0300
Merge branch 'master' into 2803-shadow-4
commit 2247c05b5521346aaf362d81ccdd64fee31f1e6d
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date: Fri Jan 29 20:53:21 2021 +0300
home: rm var shadowing, vol. 4
This commit is contained in:
@@ -556,35 +556,37 @@ func (f *Filtering) updateIntl(filter *filter) (updated bool, err error) {
|
||||
return updated, err
|
||||
}
|
||||
defer func() {
|
||||
var derr error
|
||||
if tmpFile != nil {
|
||||
if err := tmpFile.Close(); err != nil {
|
||||
log.Printf("Couldn't close temporary file: %s", err)
|
||||
}
|
||||
tmpFileName := tmpFile.Name()
|
||||
if err := os.Remove(tmpFileName); err != nil {
|
||||
log.Printf("Couldn't delete temporary file %s: %s", tmpFileName, err)
|
||||
if derr = tmpFile.Close(); derr != nil {
|
||||
log.Printf("Couldn't close temporary file: %s", derr)
|
||||
}
|
||||
|
||||
tmpFileName := tmpFile.Name()
|
||||
if derr = os.Remove(tmpFileName); derr != nil {
|
||||
log.Printf("Couldn't delete temporary file %s: %s", tmpFileName, derr)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
var reader io.Reader
|
||||
if filepath.IsAbs(filter.URL) {
|
||||
f, err := os.Open(filter.URL)
|
||||
var f io.ReadCloser
|
||||
f, err = os.Open(filter.URL)
|
||||
if err != nil {
|
||||
return updated, fmt.Errorf("open file: %w", err)
|
||||
}
|
||||
|
||||
defer f.Close()
|
||||
reader = f
|
||||
} else {
|
||||
resp, err := Context.client.Get(filter.URL)
|
||||
if resp != nil && resp.Body != nil {
|
||||
defer resp.Body.Close()
|
||||
}
|
||||
var resp *http.Response
|
||||
resp, err = Context.client.Get(filter.URL)
|
||||
if err != nil {
|
||||
log.Printf("Couldn't request filter from URL %s, skipping: %s", filter.URL, err)
|
||||
return updated, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
log.Printf("Got status code %d from URL %s, skipping", resp.StatusCode, filter.URL)
|
||||
@@ -703,7 +705,8 @@ func enableFilters(async bool) {
|
||||
if !filter.Enabled {
|
||||
continue
|
||||
}
|
||||
f := dnsfilter.Filter{
|
||||
|
||||
f = dnsfilter.Filter{
|
||||
ID: filter.ID,
|
||||
FilePath: filter.Path(),
|
||||
}
|
||||
@@ -713,7 +716,8 @@ func enableFilters(async bool) {
|
||||
if !filter.Enabled {
|
||||
continue
|
||||
}
|
||||
f := dnsfilter.Filter{
|
||||
|
||||
f = dnsfilter.Filter{
|
||||
ID: filter.ID,
|
||||
FilePath: filter.Path(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user