docstring_tokens
stringlengths
0
76.5k
code_tokens
stringlengths
75
1.81M
label_window
sequencelengths
4
2.12k
html_url
stringlengths
74
116
file_name
stringlengths
3
311
"github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" <mask> "github.com/AdguardTeam/AdGuardHome/internal/querylog" <mask> "github.com/AdguardTeam/AdGuardHome/internal/stats" <mask> "github.com/AdguardTeam/AdGuardHome/internal/version" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/google/renameio/maybe" <mask> yaml "gopkg.in/yaml.v2" <mask> ) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/config.go
<mask> "strconv" <mask> "strings" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr" <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> // getAddrsResponse is the response for /install/get_addresses endpoint. </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/controlinstall.go
defer log.OnPanic("")
<mask> // shutdownTimeout is the timeout for shutting HTTP server down operation. <mask> const shutdownTimeout = 5 * time.Second <mask> <mask> func shutdownSrv(ctx context.Context, cancel context.CancelFunc, srv *http.Server) { <mask> defer agherr.LogPanic("") <mask> <mask> if srv == nil { <mask> return <mask> } <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove func (w *Whois) query(ctx context.Context, target, serverAddr string) (string, error) { </s> add func (w *Whois) query(ctx context.Context, target, serverAddr string) (data string, err error) { </s> remove return string(data), nil </s> add return string(whoisData), nil </s> remove func (u *Updater) downloadPackageFile(url, filename string) error { resp, err := u.client.Get(url) </s> add func (u *Updater) downloadPackageFile(url, filename string) (err error) { var resp *http.Response resp, err = u.client.Get(url) </s> remove func (u *Updater) VersionInfo(forceRecheck bool) (VersionInfo, error) { </s> add func (u *Updater) VersionInfo(forceRecheck bool) (vi VersionInfo, err error) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/controlinstall.go
<mask> <mask> import ( <mask> "context" <mask> "encoding/json" <mask> "errors" <mask> "net/http" <mask> "os" <mask> "os/exec" <mask> "path/filepath" <mask> "runtime" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/controlupdate.go
"github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos" <mask> "github.com/AdguardTeam/AdGuardHome/internal/updater" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> // temporaryError is the interface for temporary errors from the Go standard </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove rDNSNotPTRErr agherr.Error = "the response is not a ptr" </s> add rDNSNotPTRErr errors.Error = "the response is not a ptr"
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/controlupdate.go
<mask> "os" <mask> "path/filepath" <mask> "strconv" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr" <mask> "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" <mask> "github.com/AdguardTeam/AdGuardHome/internal/querylog" <mask> "github.com/AdguardTeam/AdGuardHome/internal/stats" <mask> "github.com/AdguardTeam/dnsproxy/proxy" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/dns.go
"github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/querylog" <mask> "github.com/AdguardTeam/AdGuardHome/internal/stats" <mask> "github.com/AdguardTeam/dnsproxy/proxy" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/ameshkov/dnscrypt/v2" <mask> yaml "gopkg.in/yaml.v2" <mask> ) <mask> <mask> // Called by other modules when configuration is changed </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/dns.go
return dnscc, errors.Error("no dnscrypt_config_file")
<mask> } <mask> <mask> func newDNSCrypt(hosts []net.IP, tlsConf tlsConfigSettings) (dnscc dnsforward.DNSCryptConfig, err error) { <mask> if tlsConf.DNSCryptConfigFile == "" { <mask> return dnscc, agherr.Error("no dnscrypt_config_file") <mask> } <mask> <mask> f, err := os.Open(tlsConf.DNSCryptConfigFile) <mask> if err != nil { <mask> return dnscc, fmt.Errorf("opening dnscrypt config: %w", err) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer f.Close() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() </s> remove } </s> add } else if err != nil { err = fmt.Errorf("tarReader.Next(): %w", err) </s> remove defer file.Close() </s> add defer func() { err = errors.WithDeferred(err, file.Close()) }() </s> remove fi := zf.FileInfo() inputNameOnly := fi.Name() if inputNameOnly == "" { continue } outputName := filepath.Join(outdir, inputNameOnly) if fi.IsDir() { if inputNameOnly == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. continue } err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) break } log.Tracef("created directory %q", outputName) continue } var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) if err != nil { err2 = fmt.Errorf("os.OpenFile(): %w", err) break } _, err = io.Copy(f, zr) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break </s> add if name != "" { files = append(files, name) </s> remove defer func() { _ = f.Close() }() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/dns.go
defer func() { err = errors.WithDeferred(err, f.Close()) }()
<mask> f, err := os.Open(tlsConf.DNSCryptConfigFile) <mask> if err != nil { <mask> return dnscc, fmt.Errorf("opening dnscrypt config: %w", err) <mask> } <mask> defer f.Close() <mask> <mask> rc := &dnscrypt.ResolverConfig{} <mask> err = yaml.NewDecoder(f).Decode(rc) <mask> if err != nil { <mask> return dnscc, fmt.Errorf("decoding dnscrypt config: %w", err) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return dnscc, agherr.Error("no dnscrypt_config_file") </s> add return dnscc, errors.Error("no dnscrypt_config_file") </s> remove defer func() { _ = f.Close() }() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() </s> remove defer file.Close() </s> add defer func() { err = errors.WithDeferred(err, file.Close()) }() </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> remove var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(header.Mode&0o777)) if err != nil { err2 = fmt.Errorf("os.OpenFile(%s): %w", outputName, err) break } _, err = io.Copy(f, tarReader) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break } err = f.Close() if err != nil { err2 = fmt.Errorf("f.Close(): %w", err) break </s> add err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { return "", fmt.Errorf("os.Mkdir(%q): %w", outputName, err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/dns.go
<mask> package home <mask> <mask> import ( <mask> "bufio" <mask> "errors" <mask> "fmt" <mask> "hash/crc32" <mask> "io" <mask> "net/http" <mask> "os" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/filter.go
"github.com/AdguardTeam/golibs/errors"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> var nextFilterID = time.Now().Unix() // semi-stable way to generate an unique ID <mask> <mask> // Filtering - module object </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/filter.go
defer func() { err = errors.WithDeferred(err, f.Close()) }()
<mask> f, err = os.Open(filter.URL) <mask> if err != nil { <mask> return updated, fmt.Errorf("open file: %w", err) <mask> } <mask> <mask> reader = f <mask> } else { <mask> var resp *http.Response <mask> resp, err = Context.client.Get(filter.URL) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer f.Close() </s> add </s> remove func (u *Updater) downloadPackageFile(url, filename string) error { resp, err := u.client.Get(url) </s> add func (u *Updater) downloadPackageFile(url, filename string) (err error) { var resp *http.Response resp, err = u.client.Get(url) </s> remove defer file.Close() </s> add defer func() { err = errors.WithDeferred(err, file.Close()) }() </s> remove r.Body, err = aghio.LimitReadCloser(r.Body, szLim) </s> add var reader io.Reader reader, err = aghio.LimitReader(r.Body, szLim)
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/filter.go
<mask> if err != nil { <mask> return updated, fmt.Errorf("open file: %w", err) <mask> } <mask> <mask> defer f.Close() <mask> reader = f <mask> } else { <mask> var resp *http.Response <mask> resp, err = Context.client.Get(filter.URL) <mask> if err != nil { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer file.Close() </s> add defer func() { err = errors.WithDeferred(err, file.Close()) }() </s> remove func (u *Updater) downloadPackageFile(url, filename string) error { resp, err := u.client.Get(url) </s> add func (u *Updater) downloadPackageFile(url, filename string) (err error) { var resp *http.Response resp, err = u.client.Get(url) </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("etchostscontainer: closing file: %s", err) } }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/filter.go
defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }()
<mask> if err != nil { <mask> log.Printf("Couldn't request filter from URL %s, skipping: %s", filter.URL, err) <mask> return updated, err <mask> } <mask> defer resp.Body.Close() <mask> <mask> if resp.StatusCode != http.StatusOK { <mask> log.Printf("Got status code %d from URL %s, skipping", resp.StatusCode, filter.URL) <mask> return updated, fmt.Errorf("got status code != 200: %d", resp.StatusCode) <mask> } </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer f.Close() </s> add </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("etchostscontainer: closing file: %s", err) } }() </s> remove resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxPackageFileSize) </s> add var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxPackageFileSize) </s> remove defer resp.Body.Close() </s> add defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/filter.go
defer func() { err = errors.WithDeferred(err, file.Close()) }()
<mask> return nil <mask> } else if err != nil { <mask> return fmt.Errorf("opening filter file: %w", err) <mask> } <mask> defer file.Close() <mask> <mask> st, err := file.Stat() <mask> if err != nil { <mask> return fmt.Errorf("getting filter file stat: %w", err) <mask> } </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer f.Close() </s> add </s> remove } </s> add } else if err != nil { err = fmt.Errorf("tarReader.Next(): %w", err) </s> remove defer r.Close() </s> add defer func() { derr := r.Close() if derr != nil { log.Error("querylog: closing file: %s", err) } }() </s> remove defer f.Close() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/filter.go
<mask> import ( <mask> "context" <mask> "crypto/tls" <mask> "crypto/x509" <mask> "errors" <mask> "fmt" <mask> "io/fs" <mask> "net" <mask> "net/http" <mask> "net/http/pprof" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/home.go
<mask> "sync" <mask> "syscall" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr" <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet" <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos" <mask> "github.com/AdguardTeam/AdGuardHome/internal/dhcpd" <mask> "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/home.go
"github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/updater" <mask> "github.com/AdguardTeam/AdGuardHome/internal/version" <mask> "github.com/AdguardTeam/golibs/log" <mask> "gopkg.in/natefinch/lumberjack.v2" <mask> ) <mask> <mask> const ( </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors"
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/home.go
return nil, errors.List(fmt.Sprintf("couldn't dial to %s", addr), dialErrs...)
<mask> <mask> return conn, err <mask> } <mask> <mask> return nil, agherr.Many(fmt.Sprintf("couldn't dial to %s", addr), dialErrs...) <mask> } <mask> <mask> func getHTTPProxy(_ *http.Request) (*url.URL, error) { <mask> if config.ProxyURL == "" { <mask> return nil, nil </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return nil, "", errors.New("tls: failed to parse private key") </s> add return nil, "", errors.Error("tls: failed to parse private key") </s> remove return nil, errors.New("couldn't find any legible interface") </s> add return nil, errors.Error("couldn't find any legible interface") </s> remove defer agherr.Annotate("normalizing %q: %w", &err, hostname) </s> add defer func() { err = errors.Annotate(err, "normalizing %q: %w", hostname) }() </s> remove defer agherr.LogPanic("systemResolvers") </s> add defer log.OnPanic("systemResolvers") </s> remove return dnscc, agherr.Error("no dnscrypt_config_file") </s> add return dnscc, errors.Error("no dnscrypt_config_file")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/home.go
"io"
<mask> package home <mask> <mask> import ( <mask> "net/http" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghio" <mask> <mask> "github.com/AdguardTeam/golibs/log" <mask> ) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/middlewares.go
var reader io.Reader reader, err = aghio.LimitReader(r.Body, szLim)
<mask> if expectsLargerRequests(r) { <mask> szLim = largerReqBodySzLim <mask> } <mask> <mask> r.Body, err = aghio.LimitReadCloser(r.Body, szLim) <mask> if err != nil { <mask> log.Error("limitRequestBody: %s", err) <mask> <mask> return <mask> } </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer f.Close() fileReadCloser, err := aghio.LimitReadCloser(f, MaxFileSize) </s> add defer func() { derr := f.Close() if derr != nil { log.Error("glinet: closing file: %s", err) } }() fileReader, err := aghio.LimitReader(f, MaxFileSize) </s> remove defer r.Close() </s> add defer func() { derr := r.Close() if derr != nil { log.Error("querylog: closing file: %s", err) } }() </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("etchostscontainer: closing file: %s", err) } }() </s> remove defer f.Close() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() </s> remove err := e.Encode(entry) </s> add err = e.Encode(entry)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/middlewares.go
// HTTP handlers aren't supposed to call r.Body.Close(), so just // replace the body in a clone. rr := r.Clone(r.Context()) rr.Body = io.NopCloser(reader) h.ServeHTTP(w, rr)
<mask> <mask> return <mask> } <mask> <mask> h.ServeHTTP(w, r) <mask> }) <mask> } <mask> <mask> // wrapIndexBeta returns handler that deals with new client. <mask> func (web *Web) wrapIndexBeta(http.Handler) (wrapped http.Handler) { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove // We don't use an agherr.Error to avoid the import cycle since aghtests // used to provide the utilities for testing which agherr (and any other // testable package) should be able to use. </s> add </s> remove defer agherr.Annotate("normalizing %q: %w", &err, hostname) </s> add defer func() { err = errors.Annotate(err, "normalizing %q: %w", hostname) }() </s> remove defer agherr.Annotate("invalid ip range: %w", &err) </s> add defer func() { err = errors.Annotate(err, "invalid ip range: %w") }() </s> remove defer agherr.Annotate("validating domain name %q: %w", &err, name) </s> add defer func() { err = errors.Annotate(err, "validating domain name %q: %w", name) }() </s> remove return nil, agherr.Error("invalid ip") </s> add return nil, errors.Error("invalid ip")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/middlewares.go
<mask> "encoding/binary" <mask> "net" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr" <mask> "github.com/AdguardTeam/AdGuardHome/internal/dnsforward" <mask> "github.com/AdguardTeam/golibs/cache" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "errors" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/rdns.go
defer log.OnPanic("rdns")
<mask> <mask> // workerLoop handles incoming IP addresses from ipChan and adds it into <mask> // clients. <mask> func (r *RDNS) workerLoop() { <mask> defer agherr.LogPanic("rdns") <mask> <mask> for ip := range r.ipCh { <mask> host, err := r.exchanger.Exchange(ip) <mask> if err != nil { <mask> log.Debug("rdns: resolving %q: %s", ip, err) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("etchostscontainer: closing file: %s", err) } }() </s> remove defer agherr.Annotate("invalid ip range: %w", &err) </s> add defer func() { err = errors.Annotate(err, "invalid ip range: %w") }() </s> remove defer agherr.Annotate("validating domain name %q: %w", &err, name) </s> add defer func() { err = errors.Annotate(err, "validating domain name %q: %w", name) }() </s> remove err := e.Encode(entry) </s> add err = e.Encode(entry) </s> remove defer agherr.Annotate("dhcpv4: adding static lease: %w", &err) </s> add defer func() { err = errors.Annotate(err, "dhcpv4: adding static lease: %w") }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/rdns.go
<mask> <mask> import ( <mask> "bytes" <mask> "encoding/binary" <mask> "errors" <mask> "net" <mask> "sync" <mask> "testing" <mask> "time" <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/rdns_test.go
"github.com/AdguardTeam/golibs/errors"
<mask> "github.com/AdguardTeam/AdGuardHome/internal/aghtest" <mask> "github.com/AdguardTeam/dnsproxy/upstream" <mask> "github.com/AdguardTeam/golibs/cache" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/miekg/dns" <mask> "github.com/stretchr/testify/assert" <mask> ) <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/rdns_test.go
Err: errors.Error("1234"),
<mask> "2a00:1450:400c:c06::93": {"ipv6.domain"}, <mask> }, <mask> } <mask> errUpstream := &aghtest.TestErrUpstream{ <mask> Err: errors.New("1234"), <mask> } <mask> <mask> testCases := []struct { <mask> ups upstream.Upstream <mask> wantLog string </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove upstreamErr := agherr.Error("upstream error") </s> add upstreamErr := errors.Error("upstream error") </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("etchostscontainer: closing file: %s", err) } }() </s> remove outputName := filepath.Join(outdir, inputNameOnly) </s> add var name string name, err = tarGzFileUnpackOne(outDir, tarReader, hdr) </s> remove var files []string var err2 error var zr io.ReadCloser for _, zf := range r.File { zr, err = zf.Open() </s> add for _, zf := range zrc.File { var name string name, err = zipFileUnpackOne(outDir, zf) </s> remove defer agherr.Annotate("parsing %q: %w", &err, host) </s> add defer func() { err = errors.Annotate(err, "parsing %q: %w", host) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/rdns_test.go
<mask> package home <mask> <mask> import ( <mask> "errors" <mask> "fmt" <mask> "io/fs" <mask> "os" <mask> "runtime" <mask> "strconv" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/service.go
"github.com/AdguardTeam/golibs/errors"
<mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghos" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/kardianos/service" <mask> ) <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/service.go
<mask> "crypto/x509" <mask> "encoding/base64" <mask> "encoding/json" <mask> "encoding/pem" <mask> "errors" <mask> "fmt" <mask> "net/http" <mask> "os" <mask> "path/filepath" <mask> "reflect" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/tls.go
"github.com/AdguardTeam/golibs/errors"
<mask> "strings" <mask> "sync" <mask> "time" <mask> <mask> "github.com/AdguardTeam/golibs/log" <mask> "golang.org/x/sys/cpu" <mask> ) <mask> <mask> var tlsWebHandlersRegistered = false <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/tls.go
return errors.Error(data.WarningValidation)
<mask> for _, cert := range certs { <mask> parsed, err := x509.ParseCertificate(cert.Bytes) <mask> if err != nil { <mask> data.WarningValidation = fmt.Sprintf("Failed to parse certificate: %s", err) <mask> return errors.New(data.WarningValidation) <mask> } <mask> parsedCerts = append(parsedCerts, parsed) <mask> } <mask> <mask> if len(parsedCerts) == 0 { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove err := e.Encode(entry) </s> add err = e.Encode(entry) </s> remove return nil, errors.New("couldn't find any legible interface") </s> add return nil, errors.Error("couldn't find any legible interface")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/tls.go
return errors.Error(data.WarningValidation)
<mask> } <mask> <mask> if len(parsedCerts) == 0 { <mask> data.WarningValidation = "You have specified an empty certificate" <mask> return errors.New(data.WarningValidation) <mask> } <mask> <mask> data.ValidCert = true <mask> <mask> // spew.Dump(parsedCerts) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove func (l *queryLog) flushToFile(buffer []*logEntry) error { </s> add func (l *queryLog) flushToFile(buffer []*logEntry) (err error) { </s> remove defer agherr.Annotate("normalizing %q: %w", &err, hostname) </s> add defer func() { err = errors.Annotate(err, "normalizing %q: %w", hostname) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/tls.go
return errors.Error(data.WarningValidation)
<mask> } <mask> <mask> if key == nil { <mask> data.WarningValidation = "No valid keys were found" <mask> return errors.New(data.WarningValidation) <mask> } <mask> <mask> // parse the decoded key <mask> _, keytype, err := parsePrivateKey(key.Bytes) <mask> if err != nil { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove return nil, "", errors.New("tls: found unknown private key type in PKCS#8 wrapping") </s> add return nil, "", errors.Error("tls: found unknown private key type in PKCS#8 wrapping") </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove } </s> add } else if err != nil { err = fmt.Errorf("tarReader.Next(): %w", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/tls.go
return errors.Error(data.WarningValidation)
<mask> // parse the decoded key <mask> _, keytype, err := parsePrivateKey(key.Bytes) <mask> if err != nil { <mask> data.WarningValidation = fmt.Sprintf("Failed to parse private key: %s", err) <mask> return errors.New(data.WarningValidation) <mask> } <mask> <mask> data.ValidKey = true <mask> data.KeyType = keytype <mask> return nil </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove return nil, "", errors.New("tls: failed to parse private key") </s> add return nil, "", errors.Error("tls: failed to parse private key") </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove return nil, "", errors.New("tls: found unknown private key type in PKCS#8 wrapping") </s> add return nil, "", errors.Error("tls: found unknown private key type in PKCS#8 wrapping")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/tls.go
return nil, "", errors.Error("tls: found unknown private key type in PKCS#8 wrapping")
<mask> return key, "RSA", nil <mask> case *ecdsa.PrivateKey: <mask> return key, "ECDSA", nil <mask> default: <mask> return nil, "", errors.New("tls: found unknown private key type in PKCS#8 wrapping") <mask> } <mask> } <mask> <mask> if key, err := x509.ParseECPrivateKey(der); err == nil { <mask> return key, "ECDSA", nil </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return nil, "", errors.New("tls: failed to parse private key") </s> add return nil, "", errors.Error("tls: failed to parse private key") </s> remove log.Debug("updater: created directory %q", outputName) </s> add fi := zf.FileInfo() name = fi.Name() if name == "" { return "", nil } </s> remove return agherr.Error("no client ip") </s> add return errors.Error("no client ip") </s> remove continue } else if header.Typeflag != tar.TypeReg { log.Debug("updater: %s: unknown file type %d, skipping", inputNameOnly, header.Typeflag) continue </s> add outputName := filepath.Join(outDir, name) if fi.IsDir() { if name == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. return "", nil </s> remove return agherr.Error("no host in question") </s> add return errors.Error("no host in question")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/tls.go
return nil, "", errors.Error("tls: failed to parse private key")
<mask> if key, err := x509.ParseECPrivateKey(der); err == nil { <mask> return key, "ECDSA", nil <mask> } <mask> <mask> return nil, "", errors.New("tls: failed to parse private key") <mask> } <mask> <mask> // unmarshalTLS handles base64-encoded certificates transparently <mask> func unmarshalTLS(r *http.Request) (tlsConfigSettings, error) { <mask> data := tlsConfigSettings{} </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return nil, "", errors.New("tls: found unknown private key type in PKCS#8 wrapping") </s> add return nil, "", errors.Error("tls: found unknown private key type in PKCS#8 wrapping") </s> remove return nil, agherr.Many(fmt.Sprintf("couldn't dial to %s", addr), dialErrs...) </s> add return nil, errors.List(fmt.Sprintf("couldn't dial to %s", addr), dialErrs...) </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove return nil, agherr.Error("invalid ip") </s> add return nil, errors.Error("invalid ip")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/tls.go
<mask> package home <mask> <mask> import ( <mask> "errors" <mask> "fmt" <mask> "net/url" <mask> "os" <mask> "path" <mask> "path/filepath" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/upgrade.go
"github.com/AdguardTeam/golibs/errors"
<mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghnet" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/google/renameio/maybe" <mask> "golang.org/x/crypto/bcrypt" <mask> yaml "gopkg.in/yaml.v2" <mask> ) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/upgrade.go
"github.com/AdguardTeam/golibs/errors"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghio" <mask> "github.com/AdguardTeam/golibs/cache" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> const ( <mask> defaultServer = "whois.arin.net" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors"
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/whois.go
func (w *Whois) query(ctx context.Context, target, serverAddr string) (data string, err error) {
<mask> // MaxConnReadSize is an upper limit in bytes for reading from net.Conn. <mask> const MaxConnReadSize = 64 * 1024 <mask> <mask> // Send request to a server and receive the response <mask> func (w *Whois) query(ctx context.Context, target, serverAddr string) (string, error) { <mask> addr, _, _ := net.SplitHostPort(serverAddr) <mask> if addr == "whois.arin.net" { <mask> target = "n + " + target <mask> } <mask> conn, err := w.dialContext(ctx, "tcp", serverAddr) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return string(data), nil </s> add return string(whoisData), nil </s> remove func (u *Updater) downloadPackageFile(url, filename string) error { resp, err := u.client.Get(url) </s> add func (u *Updater) downloadPackageFile(url, filename string) (err error) { var resp *http.Response resp, err = u.client.Get(url) </s> remove defer agherr.LogPanic("") </s> add defer log.OnPanic("") </s> remove defer conn.Close() </s> add defer func() { err = errors.WithDeferred(err, conn.Close()) }() </s> remove defer connReadCloser.Close() </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/whois.go
defer func() { err = errors.WithDeferred(err, conn.Close()) }()
<mask> conn, err := w.dialContext(ctx, "tcp", serverAddr) <mask> if err != nil { <mask> return "", err <mask> } <mask> defer conn.Close() <mask> <mask> connReadCloser, err := aghio.LimitReadCloser(conn, MaxConnReadSize) <mask> if err != nil { <mask> return "", err <mask> } </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove connReadCloser, err := aghio.LimitReadCloser(conn, MaxConnReadSize) </s> add r, err := aghio.LimitReader(conn, MaxConnReadSize) </s> remove defer connReadCloser.Close() </s> add </s> remove func (w *Whois) query(ctx context.Context, target, serverAddr string) (string, error) { </s> add func (w *Whois) query(ctx context.Context, target, serverAddr string) (data string, err error) { </s> remove data, err := io.ReadAll(connReadCloser) </s> add var whoisData []byte whoisData, err = io.ReadAll(r) </s> remove return string(data), nil </s> add return string(whoisData), nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/whois.go
r, err := aghio.LimitReader(conn, MaxConnReadSize)
<mask> return "", err <mask> } <mask> defer conn.Close() <mask> <mask> connReadCloser, err := aghio.LimitReadCloser(conn, MaxConnReadSize) <mask> if err != nil { <mask> return "", err <mask> } <mask> defer connReadCloser.Close() <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer conn.Close() </s> add defer func() { err = errors.WithDeferred(err, conn.Close()) }() </s> remove defer connReadCloser.Close() </s> add </s> remove data, err := io.ReadAll(connReadCloser) </s> add var whoisData []byte whoisData, err = io.ReadAll(r) </s> remove return "", false, agherr.Error("duplicated separator") </s> add return "", false, errors.Error("duplicated separator") </s> remove return nil, "", errors.New("tls: failed to parse private key") </s> add return nil, "", errors.Error("tls: failed to parse private key")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/whois.go
<mask> connReadCloser, err := aghio.LimitReadCloser(conn, MaxConnReadSize) <mask> if err != nil { <mask> return "", err <mask> } <mask> defer connReadCloser.Close() <mask> <mask> _ = conn.SetReadDeadline(time.Now().Add(time.Duration(w.timeoutMsec) * time.Millisecond)) <mask> _, err = conn.Write([]byte(target + "\r\n")) <mask> if err != nil { <mask> return "", err </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove connReadCloser, err := aghio.LimitReadCloser(conn, MaxConnReadSize) </s> add r, err := aghio.LimitReader(conn, MaxConnReadSize) </s> remove defer conn.Close() </s> add defer func() { err = errors.WithDeferred(err, conn.Close()) }() </s> remove _ = gzReader.Close() return files, err2 </s> add var wc io.WriteCloser wc, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) if err != nil { return "", fmt.Errorf("os.OpenFile(): %w", err) } defer func() { err = errors.WithDeferred(err, wc.Close()) }() _, err = io.Copy(wc, rc) if err != nil { return "", fmt.Errorf("io.Copy(): %w", err) } log.Tracef("created file %s", outputName) return name, nil </s> remove data, err := io.ReadAll(connReadCloser) </s> add var whoisData []byte whoisData, err = io.ReadAll(r) </s> remove var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(header.Mode&0o777)) if err != nil { err2 = fmt.Errorf("os.OpenFile(%s): %w", outputName, err) break } _, err = io.Copy(f, tarReader) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break } err = f.Close() if err != nil { err2 = fmt.Errorf("f.Close(): %w", err) break </s> add err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { return "", fmt.Errorf("os.Mkdir(%q): %w", outputName, err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/whois.go
var whoisData []byte whoisData, err = io.ReadAll(r)
<mask> return "", err <mask> } <mask> <mask> // This use of ReadAll is now safe, because we limited the conn Reader. <mask> data, err := io.ReadAll(connReadCloser) <mask> if err != nil { <mask> return "", err <mask> } <mask> <mask> return string(data), nil </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer fileReadCloser.Close() </s> add </s> remove body, err := io.ReadAll(resp.Body) </s> add body, err := io.ReadAll(r) </s> remove defer resp.Body.Close() </s> add </s> remove bs, err := io.ReadAll(fileReadCloser) </s> add bs, err := io.ReadAll(fileReader) </s> remove defer resp.Body.Close() </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/whois.go
return string(whoisData), nil
<mask> if err != nil { <mask> return "", err <mask> } <mask> <mask> return string(data), nil <mask> } <mask> <mask> // Query WHOIS servers (handle redirects) <mask> func (w *Whois) queryAll(ctx context.Context, target string) (string, error) { <mask> server := net.JoinHostPort(defaultServer, defaultPort) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove func (w *Whois) query(ctx context.Context, target, serverAddr string) (string, error) { </s> add func (w *Whois) query(ctx context.Context, target, serverAddr string) (data string, err error) { </s> remove data, err := io.ReadAll(connReadCloser) </s> add var whoisData []byte whoisData, err = io.ReadAll(r) </s> remove defer agherr.LogPanic("") </s> add defer log.OnPanic("") </s> remove defer conn.Close() </s> add defer func() { err = errors.WithDeferred(err, conn.Close()) }() </s> remove return nil, "", errors.New("tls: failed to parse private key") </s> add return nil, "", errors.Error("tls: failed to parse private key")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/home/whois.go
<mask> // Package querylog provides query log functions and interfaces. <mask> package querylog <mask> <mask> import ( <mask> "errors" <mask> "fmt" <mask> "net" <mask> "os" <mask> "strings" <mask> "sync" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/qlog.go
"github.com/AdguardTeam/golibs/errors"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/miekg/dns" <mask> ) <mask> <mask> const ( </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors"
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/qlog.go
"github.com/AdguardTeam/golibs/errors"
<mask> "strings" <mask> "sync" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> // Timestamp not found errors. <mask> const ( </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove ErrTSNotFound agherr.Error = "ts not found" ErrTSTooLate agherr.Error = "ts too late" ErrTSTooEarly agherr.Error = "ts too early" </s> add ErrTSNotFound errors.Error = "ts not found" ErrTSTooLate errors.Error = "ts too late" ErrTSTooEarly errors.Error = "ts too early" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/qlogfile.go
ErrTSNotFound errors.Error = "ts not found" ErrTSTooLate errors.Error = "ts too late" ErrTSTooEarly errors.Error = "ts too early"
<mask> ) <mask> <mask> // Timestamp not found errors. <mask> const ( <mask> ErrTSNotFound agherr.Error = "ts not found" <mask> ErrTSTooLate agherr.Error = "ts too late" <mask> ErrTSTooEarly agherr.Error = "ts too early" <mask> ) <mask> <mask> // TODO: Find a way to grow buffer instead of relying on this value when reading strings <mask> const maxEntrySize = 16 * 1024 <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove rDNSEmptyAnswerErr agherr.Error = "the answer section is empty" </s> add rDNSEmptyAnswerErr errors.Error = "the answer section is empty" </s> remove errBadAddrPassed agherr.Error = "the passed string is not a valid IP address" </s> add errBadAddrPassed errors.Error = "the passed string is not a valid IP address" </s> remove rDNSNotPTRErr agherr.Error = "the response is not a ptr" </s> add rDNSNotPTRErr errors.Error = "the response is not a ptr" </s> remove errFakeDial agherr.Error = "this error signals the successful dialFunc work" </s> add errFakeDial errors.Error = "this error signals the successful dialFunc work"
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/qlogfile.go
<mask> package querylog <mask> <mask> import ( <mask> "encoding/binary" <mask> "errors" <mask> "fmt" <mask> "io" <mask> "math" <mask> "net" <mask> "os" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/qlogfile_test.go
"github.com/AdguardTeam/golibs/errors"
<mask> "time" <mask> <mask> "github.com/stretchr/testify/assert" <mask> "github.com/stretchr/testify/require" <mask> ) <mask> <mask> // prepareTestFile prepares one test query log file with the specified lines <mask> // count. </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove func (l *queryLog) flushToFile(buffer []*logEntry) error { </s> add func (l *queryLog) flushToFile(buffer []*logEntry) (err error) { </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "errors" </s> add
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/qlogfile_test.go
<mask> package querylog <mask> <mask> import ( <mask> "errors" <mask> "fmt" <mask> "io" <mask> "os" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/qlogreader.go
"github.com/AdguardTeam/golibs/errors"
<mask> "fmt" <mask> "io" <mask> "os" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> // QLogReader allows reading from multiple query log files in the reverse order. <mask> // </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/qlogreader.go
return errors.List("error while closing QLogReader", errs...)
<mask> } <mask> } <mask> <mask> if len(errs) > 0 { <mask> return agherr.Many("Error while closing QLogReader", errs...) <mask> } <mask> <mask> return nil <mask> } </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove if len(errors) != 0 { return agherr.Many("closing ipsets", errors...) </s> add if len(errs) != 0 { return errors.List("closing ipsets", errs...) </s> remove return agherr.Error("domain name is empty") </s> add return errors.Error("domain name is empty") </s> remove defer f.Close() fileReadCloser, err := aghio.LimitReadCloser(f, MaxFileSize) </s> add defer func() { derr := f.Close() if derr != nil { log.Error("glinet: closing file: %s", err) } }() fileReader, err := aghio.LimitReader(f, MaxFileSize) </s> remove defer r.Close() </s> add defer func() { derr := r.Close() if derr != nil { log.Error("querylog: closing file: %s", err) } }() </s> remove return agherr.Error("label is empty") </s> add return errors.Error("label is empty")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/qlogreader.go
<mask> "net/http" <mask> "path/filepath" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr" <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/miekg/dns" <mask> ) <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylog.go
"github.com/AdguardTeam/golibs/errors"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/filtering" <mask> "github.com/AdguardTeam/golibs/log" <mask> "github.com/miekg/dns" <mask> ) <mask> <mask> // QueryLog - main interface <mask> type QueryLog interface { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylog.go
return errors.Error("question is nil")
<mask> // validate returns an error if the parameters aren't valid. <mask> func (p *AddParams) validate() (err error) { <mask> switch { <mask> case p.Question == nil: <mask> return agherr.Error("question is nil") <mask> case len(p.Question.Question) != 1: <mask> return agherr.Error("more than one question") <mask> case len(p.Question.Question[0].Name) == 0: <mask> return agherr.Error("no host in question") <mask> case p.ClientIP == nil: </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return agherr.Error("more than one question") </s> add return errors.Error("more than one question") </s> remove return agherr.Error("no host in question") </s> add return errors.Error("no host in question") </s> remove return agherr.Error("no client ip") </s> add return errors.Error("no client ip") </s> remove return agherr.Error("client is nil") </s> add return errors.Error("client is nil") </s> remove return agherr.Error("invalid name") </s> add return errors.Error("invalid name")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylog.go
return errors.Error("more than one question")
<mask> switch { <mask> case p.Question == nil: <mask> return agherr.Error("question is nil") <mask> case len(p.Question.Question) != 1: <mask> return agherr.Error("more than one question") <mask> case len(p.Question.Question[0].Name) == 0: <mask> return agherr.Error("no host in question") <mask> case p.ClientIP == nil: <mask> return agherr.Error("no client ip") <mask> default: </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return agherr.Error("no host in question") </s> add return errors.Error("no host in question") </s> remove return agherr.Error("no client ip") </s> add return errors.Error("no client ip") </s> remove return agherr.Error("question is nil") </s> add return errors.Error("question is nil") </s> remove return agherr.Error("invalid name") </s> add return errors.Error("invalid name") </s> remove return agherr.Error("client is nil") </s> add return errors.Error("client is nil")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylog.go
return errors.Error("no host in question")
<mask> return agherr.Error("question is nil") <mask> case len(p.Question.Question) != 1: <mask> return agherr.Error("more than one question") <mask> case len(p.Question.Question[0].Name) == 0: <mask> return agherr.Error("no host in question") <mask> case p.ClientIP == nil: <mask> return agherr.Error("no client ip") <mask> default: <mask> return nil <mask> } </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return agherr.Error("more than one question") </s> add return errors.Error("more than one question") </s> remove return agherr.Error("no client ip") </s> add return errors.Error("no client ip") </s> remove return agherr.Error("question is nil") </s> add return errors.Error("question is nil") </s> remove return agherr.Error("invalid name") </s> add return errors.Error("invalid name") </s> remove return agherr.Error("client is nil") </s> add return errors.Error("client is nil")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylog.go
return errors.Error("no client ip")
<mask> return agherr.Error("more than one question") <mask> case len(p.Question.Question[0].Name) == 0: <mask> return agherr.Error("no host in question") <mask> case p.ClientIP == nil: <mask> return agherr.Error("no client ip") <mask> default: <mask> return nil <mask> } <mask> } <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return agherr.Error("no host in question") </s> add return errors.Error("no host in question") </s> remove return agherr.Error("more than one question") </s> add return errors.Error("more than one question") </s> remove return agherr.Error("question is nil") </s> add return errors.Error("question is nil") </s> remove return agherr.Error("invalid name") </s> add return errors.Error("invalid name") </s> remove return agherr.Error("client is nil") </s> add return errors.Error("client is nil")
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylog.go
<mask> <mask> import ( <mask> "bytes" <mask> "encoding/json" <mask> "errors" <mask> "os" <mask> "time" <mask> <mask> "github.com/AdguardTeam/golibs/log" <mask> ) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylogfile.go
"github.com/AdguardTeam/golibs/errors"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> // flushLogBuffer flushes the current buffer to file and resets the current buffer <mask> func (l *queryLog) flushLogBuffer(fullFlush bool) error { <mask> if !l.conf.FileEnabled { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove func (l *queryLog) flushToFile(buffer []*logEntry) error { </s> add func (l *queryLog) flushToFile(buffer []*logEntry) (err error) { </s> remove func (u *Updater) VersionInfo(forceRecheck bool) (VersionInfo, error) { </s> add func (u *Updater) VersionInfo(forceRecheck bool) (vi VersionInfo, err error) { </s> remove err := e.Encode(entry) </s> add err = e.Encode(entry) </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors"
[ "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylogfile.go
func (l *queryLog) flushToFile(buffer []*logEntry) (err error) {
<mask> return nil <mask> } <mask> <mask> // flushToFile saves the specified log entries to the query log file <mask> func (l *queryLog) flushToFile(buffer []*logEntry) error { <mask> if len(buffer) == 0 { <mask> log.Debug("querylog: there's nothing to write to a file") <mask> return nil <mask> } <mask> start := time.Now() </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer f.Close() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove return nil, agherr.Many(fmt.Sprintf("couldn't dial to %s", addr), dialErrs...) </s> add return nil, errors.List(fmt.Sprintf("couldn't dial to %s", addr), dialErrs...)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylogfile.go
err = e.Encode(entry)
<mask> <mask> var b bytes.Buffer <mask> e := json.NewEncoder(&b) <mask> for _, entry := range buffer { <mask> err := e.Encode(entry) <mask> if err != nil { <mask> log.Error("Failed to marshal entry: %s", err) <mask> return err <mask> } <mask> } </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove var files []string var err2 error var zr io.ReadCloser for _, zf := range r.File { zr, err = zf.Open() </s> add for _, zf := range zrc.File { var name string name, err = zipFileUnpackOne(outDir, zf) </s> remove defer r.Close() </s> add defer func() { err = errors.WithDeferred(err, zrc.Close()) }() </s> remove err2 = fmt.Errorf("zip file Open(): %w", err) </s> add </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("etchostscontainer: closing file: %s", err) } }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylogfile.go
<mask> <mask> elapsed := time.Since(start) <mask> log.Debug("%d elements serialized via json in %v: %d kB, %v/entry, %v/entry", len(buffer), elapsed, b.Len()/1024, float64(b.Len())/float64(len(buffer)), elapsed/time.Duration(len(buffer))) <mask> <mask> var err error <mask> var zb bytes.Buffer <mask> filename := l.logFile <mask> zb = b <mask> <mask> l.fileWriteLock.Lock() </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove err := e.Encode(entry) </s> add err = e.Encode(entry) </s> remove func (u *Updater) downloadPackageFile(url, filename string) error { resp, err := u.client.Get(url) </s> add func (u *Updater) downloadPackageFile(url, filename string) (err error) { var resp *http.Response resp, err = u.client.Get(url) </s> remove var files []string var err2 error </s> add </s> remove defer r.Close() </s> add defer func() { err = errors.WithDeferred(err, zrc.Close()) }() </s> remove var files []string var err2 error var zr io.ReadCloser for _, zf := range r.File { zr, err = zf.Open() </s> add for _, zf := range zrc.File { var name string name, err = zipFileUnpackOne(outDir, zf)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylogfile.go
defer func() { err = errors.WithDeferred(err, f.Close()) }()
<mask> if err != nil { <mask> log.Error("failed to create file \"%s\": %s", filename, err) <mask> return err <mask> } <mask> defer f.Close() <mask> <mask> n, err := f.Write(zb.Bytes()) <mask> if err != nil { <mask> log.Error("Couldn't write to file: %s", err) <mask> return err </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("etchostscontainer: closing file: %s", err) } }() </s> remove defer f.Close() fileReadCloser, err := aghio.LimitReadCloser(f, MaxFileSize) </s> add defer func() { derr := f.Close() if derr != nil { log.Error("glinet: closing file: %s", err) } }() fileReader, err := aghio.LimitReader(f, MaxFileSize) </s> remove defer r.Close() </s> add defer func() { derr := r.Close() if derr != nil { log.Error("querylog: closing file: %s", err) } }() </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> remove err := e.Encode(entry) </s> add err = e.Encode(entry)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylogfile.go
defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }()
<mask> f, err := os.Open(l.logFile) <mask> if err != nil { <mask> return -1 <mask> } <mask> defer f.Close() <mask> <mask> buf := make([]byte, 500) <mask> r, err := f.Read(buf) <mask> if err != nil { <mask> return -1 </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer func() { _ = f.Close() }() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() </s> remove defer f.Close() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() </s> remove defer f.Close() fileReadCloser, err := aghio.LimitReadCloser(f, MaxFileSize) </s> add defer func() { derr := f.Close() if derr != nil { log.Error("glinet: closing file: %s", err) } }() fileReader, err := aghio.LimitReader(f, MaxFileSize) </s> remove connReadCloser, err := aghio.LimitReadCloser(conn, MaxConnReadSize) </s> add r, err := aghio.LimitReader(conn, MaxConnReadSize) </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("etchostscontainer: closing file: %s", err) } }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/querylogfile.go
defer func() { derr := r.Close() if derr != nil { log.Error("querylog: closing file: %s", err) } }()
<mask> log.Error("querylog: failed to open qlog reader: %s", err) <mask> <mask> return entries, oldest, 0 <mask> } <mask> defer r.Close() <mask> <mask> if params.olderThan.IsZero() { <mask> err = r.SeekStart() <mask> } else { <mask> err = r.SeekTS(params.olderThan.UnixNano()) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer f.Close() fileReadCloser, err := aghio.LimitReadCloser(f, MaxFileSize) </s> add defer func() { derr := f.Close() if derr != nil { log.Error("glinet: closing file: %s", err) } }() fileReader, err := aghio.LimitReader(f, MaxFileSize) </s> remove defer agherr.LogPanic("systemResolvers") </s> add defer log.OnPanic("systemResolvers") </s> remove defer f.Close() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() </s> remove return errors.New(data.WarningValidation) </s> add return errors.Error(data.WarningValidation) </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/querylog/search.go
<mask> import ( <mask> "bytes" <mask> "encoding/binary" <mask> "encoding/gob" <mask> "errors" <mask> "fmt" <mask> "net" <mask> "os" <mask> "sort" <mask> "sync" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/stats/unit.go
"github.com/AdguardTeam/golibs/errors"
<mask> "sort" <mask> "sync" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/agherr" <mask> "github.com/AdguardTeam/golibs/log" <mask> bolt "go.etcd.io/bbolt" <mask> ) <mask> <mask> // TODO(a.garipov): Rewrite all of this. Add proper error handling and </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/stats/unit.go
errStop := errors.Error("stop iteration")
<mask> unitDel := 0 <mask> <mask> // TODO(a.garipov): See if this is actually necessary. Looks <mask> // like a rather bizarre solution. <mask> errStop := agherr.Error("stop iteration") <mask> forEachBkt := func(name []byte, _ *bolt.Bucket) (cberr error) { <mask> nameID := uint32(btoi(name)) <mask> if nameID < firstID { <mask> cberr = tx.DeleteBucket(name) <mask> if cberr != nil { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer agherr.Annotate("invalid option string %q: %w", &err, s) </s> add defer func() { err = errors.Annotate(err, "invalid option string %q: %w", s) }() </s> remove defer agherr.Annotate("validating domain name %q: %w", &err, name) </s> add defer func() { err = errors.Annotate(err, "validating domain name %q: %w", name) }() </s> remove return nil, agherr.Error("invalid ip") </s> add return nil, errors.Error("invalid ip") </s> remove defer agherr.Annotate("validating label %q: %w", &err, label) </s> add defer func() { err = errors.Annotate(err, "validating label %q: %w", label) }() </s> remove continue } else if header.Typeflag != tar.TypeReg { log.Debug("updater: %s: unknown file type %d, skipping", inputNameOnly, header.Typeflag) continue </s> add outputName := filepath.Join(outDir, name) if fi.IsDir() { if name == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. return "", nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/stats/unit.go
"net/http"
<mask> import ( <mask> "encoding/json" <mask> "fmt" <mask> "io" <mask> "strings" <mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghio" <mask> "github.com/AdguardTeam/golibs/errors" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/check.go
"github.com/AdguardTeam/golibs/errors"
<mask> "time" <mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghio" <mask> ) <mask> <mask> // TODO(a.garipov): Make configurable. <mask> const versionCheckPeriod = 8 * time.Hour <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/check.go
func (u *Updater) VersionInfo(forceRecheck bool) (vi VersionInfo, err error) {
<mask> const MaxResponseSize = 64 * 1024 <mask> <mask> // VersionInfo downloads the latest version information. If forceRecheck is <mask> // false and there are cached results, those results are returned. <mask> func (u *Updater) VersionInfo(forceRecheck bool) (VersionInfo, error) { <mask> u.mu.Lock() <mask> defer u.mu.Unlock() <mask> <mask> now := time.Now() <mask> recheckTime := u.prevCheckTime.Add(versionCheckPeriod) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove func (u *Updater) downloadPackageFile(url, filename string) error { resp, err := u.client.Get(url) </s> add func (u *Updater) downloadPackageFile(url, filename string) (err error) { var resp *http.Response resp, err = u.client.Get(url) </s> remove func (w *Whois) query(ctx context.Context, target, serverAddr string) (string, error) { </s> add func (w *Whois) query(ctx context.Context, target, serverAddr string) (data string, err error) { </s> remove // All files are created inside 'outdir', subdirectories are not created </s> add // All files are created inside 'outDir', subdirectories are not created </s> remove // All files are created inside 'outdir', subdirectories are not created </s> add // All files are created inside outDir, subdirectories are not created </s> remove func tarGzFileUnpack(tarfile, outdir string) ([]string, error) { </s> add func tarGzFileUnpack(tarfile, outDir string) (files []string, err error) {
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/check.go
var resp *http.Response
<mask> } <mask> <mask> vcu := u.versionCheckURL <mask> resp, err = u.client.Get(vcu) <mask> if err != nil { <mask> return VersionInfo{}, fmt.Errorf("updater: HTTP GET %s: %w", vcu, err) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove resp, err := u.client.Get(vcu) </s> add resp, err = u.client.Get(vcu) </s> remove defer resp.Body.Close() </s> add defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }() </s> remove resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxResponseSize) </s> add var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxResponseSize) </s> remove body, err := io.ReadAll(resp.Body) </s> add body, err := io.ReadAll(r) </s> remove defer resp.Body.Close() </s> add
[ "keep", "add", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/check.go
resp, err = u.client.Get(vcu)
<mask> return u.prevCheckResult, u.prevCheckError <mask> } <mask> <mask> vcu := u.versionCheckURL <mask> resp, err := u.client.Get(vcu) <mask> if err != nil { <mask> return VersionInfo{}, fmt.Errorf("updater: HTTP GET %s: %w", vcu, err) <mask> } <mask> defer resp.Body.Close() <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer resp.Body.Close() </s> add defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }() </s> remove resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxResponseSize) </s> add var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxResponseSize) </s> remove body, err := io.ReadAll(resp.Body) </s> add body, err := io.ReadAll(r) </s> remove defer resp.Body.Close() </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/check.go
defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }()
<mask> resp, err := u.client.Get(vcu) <mask> if err != nil { <mask> return VersionInfo{}, fmt.Errorf("updater: HTTP GET %s: %w", vcu, err) <mask> } <mask> defer resp.Body.Close() <mask> <mask> resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxResponseSize) <mask> if err != nil { <mask> return VersionInfo{}, fmt.Errorf("updater: LimitReadCloser: %w", err) <mask> } </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxResponseSize) </s> add var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxResponseSize) </s> remove resp, err := u.client.Get(vcu) </s> add resp, err = u.client.Get(vcu) </s> remove defer resp.Body.Close() </s> add </s> remove body, err := io.ReadAll(resp.Body) </s> add body, err := io.ReadAll(r)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/check.go
var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxResponseSize)
<mask> return VersionInfo{}, fmt.Errorf("updater: HTTP GET %s: %w", vcu, err) <mask> } <mask> defer resp.Body.Close() <mask> <mask> resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxResponseSize) <mask> if err != nil { <mask> return VersionInfo{}, fmt.Errorf("updater: LimitReadCloser: %w", err) <mask> } <mask> defer resp.Body.Close() <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer resp.Body.Close() </s> add defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }() </s> remove resp, err := u.client.Get(vcu) </s> add resp, err = u.client.Get(vcu) </s> remove defer resp.Body.Close() </s> add </s> remove body, err := io.ReadAll(resp.Body) </s> add body, err := io.ReadAll(r)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/check.go
<mask> resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxResponseSize) <mask> if err != nil { <mask> return VersionInfo{}, fmt.Errorf("updater: LimitReadCloser: %w", err) <mask> } <mask> defer resp.Body.Close() <mask> <mask> // This use of ReadAll is safe, because we just limited the appropriate <mask> // ReadCloser. <mask> body, err := io.ReadAll(resp.Body) <mask> if err != nil { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove body, err := io.ReadAll(resp.Body) </s> add body, err := io.ReadAll(r) </s> remove defer resp.Body.Close() </s> add </s> remove body, err := io.ReadAll(resp.Body) </s> add body, err := io.ReadAll(r) </s> remove resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxResponseSize) </s> add var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxResponseSize) </s> remove defer resp.Body.Close() </s> add defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/check.go
body, err := io.ReadAll(r)
<mask> defer resp.Body.Close() <mask> <mask> // This use of ReadAll is safe, because we just limited the appropriate <mask> // ReadCloser. <mask> body, err := io.ReadAll(resp.Body) <mask> if err != nil { <mask> return VersionInfo{}, fmt.Errorf("updater: HTTP GET %s: %w", vcu, err) <mask> } <mask> <mask> u.prevCheckTime = time.Now() </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer resp.Body.Close() </s> add </s> remove body, err := io.ReadAll(resp.Body) </s> add body, err := io.ReadAll(r) </s> remove defer resp.Body.Close() </s> add </s> remove resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxResponseSize) </s> add var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxResponseSize) </s> remove defer fileReadCloser.Close() </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/check.go
<mask> import ( <mask> "archive/tar" <mask> "archive/zip" <mask> "compress/gzip" <mask> "errors" <mask> "fmt" <mask> "io" <mask> "net/http" <mask> "net/url" <mask> "os" </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add </s> remove "errors" </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
"github.com/AdguardTeam/golibs/errors"
<mask> <mask> "github.com/AdguardTeam/AdGuardHome/internal/aghio" <mask> "github.com/AdguardTeam/AdGuardHome/internal/version" <mask> "github.com/AdguardTeam/golibs/log" <mask> ) <mask> <mask> // Updater is the AdGuard Home updater. <mask> type Updater struct { <mask> client *http.Client </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add "github.com/AdguardTeam/golibs/errors" </s> remove "github.com/AdguardTeam/AdGuardHome/internal/agherr" </s> add
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
func (u *Updater) downloadPackageFile(url, filename string) (err error) { var resp *http.Response resp, err = u.client.Get(url)
<mask> // approximately 9 MiB. <mask> const MaxPackageFileSize = 32 * 1024 * 1024 <mask> <mask> // Download package file and save it to disk <mask> func (u *Updater) downloadPackageFile(url, filename string) error { <mask> resp, err := u.client.Get(url) <mask> if err != nil { <mask> return fmt.Errorf("http request failed: %w", err) <mask> } <mask> defer resp.Body.Close() <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer resp.Body.Close() </s> add defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }() </s> remove func (u *Updater) VersionInfo(forceRecheck bool) (VersionInfo, error) { </s> add func (u *Updater) VersionInfo(forceRecheck bool) (vi VersionInfo, err error) { </s> remove resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxPackageFileSize) </s> add var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxPackageFileSize) </s> remove func (w *Whois) query(ctx context.Context, target, serverAddr string) (string, error) { </s> add func (w *Whois) query(ctx context.Context, target, serverAddr string) (data string, err error) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }()
<mask> resp, err := u.client.Get(url) <mask> if err != nil { <mask> return fmt.Errorf("http request failed: %w", err) <mask> } <mask> defer resp.Body.Close() <mask> <mask> resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxPackageFileSize) <mask> if err != nil { <mask> return fmt.Errorf("http request failed: %w", err) <mask> } </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxPackageFileSize) </s> add var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxPackageFileSize) </s> remove defer resp.Body.Close() </s> add </s> remove func (u *Updater) downloadPackageFile(url, filename string) error { resp, err := u.client.Get(url) </s> add func (u *Updater) downloadPackageFile(url, filename string) (err error) { var resp *http.Response resp, err = u.client.Get(url) </s> remove defer resp.Body.Close() </s> add defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }() </s> remove resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxResponseSize) </s> add var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxResponseSize)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxPackageFileSize)
<mask> return fmt.Errorf("http request failed: %w", err) <mask> } <mask> defer resp.Body.Close() <mask> <mask> resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxPackageFileSize) <mask> if err != nil { <mask> return fmt.Errorf("http request failed: %w", err) <mask> } <mask> defer resp.Body.Close() <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer resp.Body.Close() </s> add defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }() </s> remove defer resp.Body.Close() </s> add </s> remove func (u *Updater) downloadPackageFile(url, filename string) error { resp, err := u.client.Get(url) </s> add func (u *Updater) downloadPackageFile(url, filename string) (err error) { var resp *http.Response resp, err = u.client.Get(url) </s> remove resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxResponseSize) </s> add var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxResponseSize) </s> remove defer resp.Body.Close() </s> add defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
<mask> resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxPackageFileSize) <mask> if err != nil { <mask> return fmt.Errorf("http request failed: %w", err) <mask> } <mask> defer resp.Body.Close() <mask> <mask> log.Debug("updater: reading HTTP body") <mask> // This use of ReadAll is now safe, because we limited body's Reader. <mask> body, err := io.ReadAll(resp.Body) <mask> if err != nil { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove body, err := io.ReadAll(resp.Body) </s> add body, err := io.ReadAll(r) </s> remove defer resp.Body.Close() </s> add </s> remove body, err := io.ReadAll(resp.Body) </s> add body, err := io.ReadAll(r) </s> remove resp.Body, err = aghio.LimitReadCloser(resp.Body, MaxPackageFileSize) </s> add var r io.Reader r, err = aghio.LimitReader(resp.Body, MaxPackageFileSize) </s> remove defer resp.Body.Close() </s> add defer func() { err = errors.WithDeferred(err, resp.Body.Close()) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
body, err := io.ReadAll(r)
<mask> defer resp.Body.Close() <mask> <mask> log.Debug("updater: reading HTTP body") <mask> // This use of ReadAll is now safe, because we limited body's Reader. <mask> body, err := io.ReadAll(resp.Body) <mask> if err != nil { <mask> return fmt.Errorf("io.ReadAll() failed: %w", err) <mask> } <mask> <mask> _ = os.Mkdir(u.updateDir, 0o755) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer resp.Body.Close() </s> add </s> remove body, err := io.ReadAll(resp.Body) </s> add body, err := io.ReadAll(r) </s> remove defer resp.Body.Close() </s> add </s> remove defer fileReadCloser.Close() </s> add </s> remove data, err := io.ReadAll(connReadCloser) </s> add var whoisData []byte whoisData, err = io.ReadAll(r)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
// All files are created inside outDir, subdirectories are not created
<mask> } <mask> <mask> // Unpack all files from .tar.gz file to the specified directory <mask> // Existing files are overwritten <mask> // All files are created inside 'outdir', subdirectories are not created <mask> // Return the list of files (not directories) written <mask> func tarGzFileUnpack(tarfile, outdir string) ([]string, error) { <mask> f, err := os.Open(tarfile) <mask> if err != nil { <mask> return nil, fmt.Errorf("os.Open(): %w", err) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove func tarGzFileUnpack(tarfile, outdir string) ([]string, error) { </s> add func tarGzFileUnpack(tarfile, outDir string) (files []string, err error) { </s> remove // All files are created inside 'outdir', subdirectories are not created </s> add // All files are created inside 'outDir', subdirectories are not created </s> remove func zipFileUnpack(zipfile, outdir string) ([]string, error) { r, err := zip.OpenReader(zipfile) </s> add func zipFileUnpack(zipfile, outDir string) (files []string, err error) { zrc, err := zip.OpenReader(zipfile) </s> remove _ = gzReader.Close() return files, err2 </s> add var wc io.WriteCloser wc, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) if err != nil { return "", fmt.Errorf("os.OpenFile(): %w", err) } defer func() { err = errors.WithDeferred(err, wc.Close()) }() _, err = io.Copy(wc, rc) if err != nil { return "", fmt.Errorf("io.Copy(): %w", err) } log.Tracef("created file %s", outputName) return name, nil </s> remove log.Debug("updater: created file %s", outputName) files = append(files, header.Name) </s> add log.Tracef("created directory %q", outputName) return "", nil
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
func tarGzFileUnpack(tarfile, outDir string) (files []string, err error) {
<mask> // Unpack all files from .tar.gz file to the specified directory <mask> // Existing files are overwritten <mask> // All files are created inside 'outdir', subdirectories are not created <mask> // Return the list of files (not directories) written <mask> func tarGzFileUnpack(tarfile, outdir string) ([]string, error) { <mask> f, err := os.Open(tarfile) <mask> if err != nil { <mask> return nil, fmt.Errorf("os.Open(): %w", err) <mask> } <mask> defer func() { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove // All files are created inside 'outdir', subdirectories are not created </s> add // All files are created inside outDir, subdirectories are not created </s> remove // All files are created inside 'outdir', subdirectories are not created </s> add // All files are created inside 'outDir', subdirectories are not created </s> remove func zipFileUnpack(zipfile, outdir string) ([]string, error) { r, err := zip.OpenReader(zipfile) </s> add func zipFileUnpack(zipfile, outDir string) (files []string, err error) { zrc, err := zip.OpenReader(zipfile) </s> remove _ = gzReader.Close() return files, err2 </s> add var wc io.WriteCloser wc, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) if err != nil { return "", fmt.Errorf("os.OpenFile(): %w", err) } defer func() { err = errors.WithDeferred(err, wc.Close()) }() _, err = io.Copy(wc, rc) if err != nil { return "", fmt.Errorf("io.Copy(): %w", err) } log.Tracef("created file %s", outputName) return name, nil </s> remove defer func() { _ = f.Close() }() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }()
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
defer func() { err = errors.WithDeferred(err, f.Close()) }()
<mask> f, err := os.Open(tarfile) <mask> if err != nil { <mask> return nil, fmt.Errorf("os.Open(): %w", err) <mask> } <mask> defer func() { <mask> _ = f.Close() <mask> }() <mask> <mask> gzReader, err := gzip.NewReader(f) <mask> if err != nil { <mask> return nil, fmt.Errorf("gzip.NewReader(): %w", err) <mask> } </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove defer f.Close() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() </s> remove var files []string var err2 error </s> add </s> remove defer f.Close() </s> add defer func() { derr := f.Close() if derr != nil { log.Error("querylog: closing file: %s", derr) } }() </s> remove func tarGzFileUnpack(tarfile, outdir string) ([]string, error) { </s> add func tarGzFileUnpack(tarfile, outDir string) (files []string, err error) {
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
defer func() { err = errors.WithDeferred(err, gzReader.Close()) }()
<mask> if err != nil { <mask> return nil, fmt.Errorf("gzip.NewReader(): %w", err) <mask> } <mask> <mask> tarReader := tar.NewReader(gzReader) <mask> for { <mask> var hdr *tar.Header <mask> hdr, err = tarReader.Next() </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove var files []string var err2 error </s> add </s> remove var header *tar.Header header, err = tarReader.Next() if err == io.EOF { err2 = nil break } if err != nil { err2 = fmt.Errorf("tarReader.Next(): %w", err) </s> add var hdr *tar.Header hdr, err = tarReader.Next() if errors.Is(err, io.EOF) { err = nil </s> remove defer func() { _ = f.Close() }() </s> add defer func() { err = errors.WithDeferred(err, f.Close()) }() </s> remove var files []string var err2 error var zr io.ReadCloser for _, zf := range r.File { zr, err = zf.Open() </s> add for _, zf := range zrc.File { var name string name, err = zipFileUnpackOne(outDir, zf) </s> remove defer r.Close() </s> add defer func() { err = errors.WithDeferred(err, zrc.Close()) }()
[ "keep", "keep", "add", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
<mask> if err != nil { <mask> return nil, fmt.Errorf("gzip.NewReader(): %w", err) <mask> } <mask> <mask> var files []string <mask> var err2 error <mask> tarReader := tar.NewReader(gzReader) <mask> for { <mask> var header *tar.Header <mask> header, err = tarReader.Next() <mask> if err == io.EOF { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove var header *tar.Header header, err = tarReader.Next() if err == io.EOF { err2 = nil break } if err != nil { err2 = fmt.Errorf("tarReader.Next(): %w", err) </s> add var hdr *tar.Header hdr, err = tarReader.Next() if errors.Is(err, io.EOF) { err = nil </s> remove defer r.Close() </s> add defer func() { err = errors.WithDeferred(err, zrc.Close()) }() </s> remove var files []string var err2 error var zr io.ReadCloser for _, zf := range r.File { zr, err = zf.Open() </s> add for _, zf := range zrc.File { var name string name, err = zipFileUnpackOne(outDir, zf) </s> remove var stdoutLimited io.ReadCloser stdoutLimited, err = aghio.LimitReadCloser(stdout, aghos.MaxCmdOutputSize) </s> add var stdoutLimited io.Reader stdoutLimited, err = aghio.LimitReader(stdout, aghos.MaxCmdOutputSize)
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
var hdr *tar.Header hdr, err = tarReader.Next() if errors.Is(err, io.EOF) { err = nil
<mask> var files []string <mask> var err2 error <mask> tarReader := tar.NewReader(gzReader) <mask> for { <mask> var header *tar.Header <mask> header, err = tarReader.Next() <mask> if err == io.EOF { <mask> err2 = nil <mask> break <mask> } <mask> if err != nil { <mask> err2 = fmt.Errorf("tarReader.Next(): %w", err) <mask> break <mask> } <mask> <mask> _, inputNameOnly := filepath.Split(header.Name) <mask> if inputNameOnly == "" { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove var files []string var err2 error </s> add </s> remove _, inputNameOnly := filepath.Split(header.Name) if inputNameOnly == "" { continue </s> add break </s> remove } </s> add } else if err != nil { err = fmt.Errorf("tarReader.Next(): %w", err) </s> remove var files []string var err2 error var zr io.ReadCloser for _, zf := range r.File { zr, err = zf.Open() </s> add for _, zf := range zrc.File { var name string name, err = zipFileUnpackOne(outDir, zf) </s> remove fi := zf.FileInfo() inputNameOnly := fi.Name() if inputNameOnly == "" { continue } outputName := filepath.Join(outdir, inputNameOnly) if fi.IsDir() { if inputNameOnly == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. continue } err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) break } log.Tracef("created directory %q", outputName) continue } var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) if err != nil { err2 = fmt.Errorf("os.OpenFile(): %w", err) break } _, err = io.Copy(f, zr) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break </s> add if name != "" { files = append(files, name)
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
} else if err != nil { err = fmt.Errorf("tarReader.Next(): %w", err)
<mask> } <mask> if err != nil { <mask> err2 = fmt.Errorf("tarReader.Next(): %w", err) <mask> break <mask> } <mask> <mask> _, inputNameOnly := filepath.Split(header.Name) <mask> if inputNameOnly == "" { <mask> continue <mask> } </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove _, inputNameOnly := filepath.Split(header.Name) if inputNameOnly == "" { continue </s> add break </s> remove var header *tar.Header header, err = tarReader.Next() if err == io.EOF { err2 = nil break } if err != nil { err2 = fmt.Errorf("tarReader.Next(): %w", err) </s> add var hdr *tar.Header hdr, err = tarReader.Next() if errors.Is(err, io.EOF) { err = nil </s> remove fi := zf.FileInfo() inputNameOnly := fi.Name() if inputNameOnly == "" { continue } outputName := filepath.Join(outdir, inputNameOnly) if fi.IsDir() { if inputNameOnly == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. continue } err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) break } log.Tracef("created directory %q", outputName) continue } var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) if err != nil { err2 = fmt.Errorf("os.OpenFile(): %w", err) break } _, err = io.Copy(f, zr) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break </s> add if name != "" { files = append(files, name) </s> remove outputName := filepath.Join(outdir, inputNameOnly) </s> add var name string name, err = tarGzFileUnpackOne(outDir, tarReader, hdr) </s> remove err2 = fmt.Errorf("zip file Open(): %w", err) </s> add
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
break
<mask> err2 = fmt.Errorf("tarReader.Next(): %w", err) <mask> break <mask> } <mask> <mask> _, inputNameOnly := filepath.Split(header.Name) <mask> if inputNameOnly == "" { <mask> continue <mask> } <mask> <mask> outputName := filepath.Join(outdir, inputNameOnly) <mask> <mask> if header.Typeflag == tar.TypeDir { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove } </s> add } else if err != nil { err = fmt.Errorf("tarReader.Next(): %w", err) </s> remove outputName := filepath.Join(outdir, inputNameOnly) </s> add var name string name, err = tarGzFileUnpackOne(outDir, tarReader, hdr) </s> remove var header *tar.Header header, err = tarReader.Next() if err == io.EOF { err2 = nil break } if err != nil { err2 = fmt.Errorf("tarReader.Next(): %w", err) </s> add var hdr *tar.Header hdr, err = tarReader.Next() if errors.Is(err, io.EOF) { err = nil </s> remove fi := zf.FileInfo() inputNameOnly := fi.Name() if inputNameOnly == "" { continue } outputName := filepath.Join(outdir, inputNameOnly) if fi.IsDir() { if inputNameOnly == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. continue } err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) break } log.Tracef("created directory %q", outputName) continue } var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) if err != nil { err2 = fmt.Errorf("os.OpenFile(): %w", err) break } _, err = io.Copy(f, zr) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break </s> add if name != "" { files = append(files, name) </s> remove if header.Typeflag == tar.TypeDir { if inputNameOnly == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): This whole package needs to // be rewritten and covered in more integration // tests. It has weird assumptions and file // mode issues. continue } </s> add if name != "" { files = append(files, name) } }
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
var name string name, err = tarGzFileUnpackOne(outDir, tarReader, hdr)
<mask> if inputNameOnly == "" { <mask> continue <mask> } <mask> <mask> outputName := filepath.Join(outdir, inputNameOnly) <mask> <mask> if header.Typeflag == tar.TypeDir { <mask> if inputNameOnly == "AdGuardHome" { <mask> // Top-level AdGuardHome/. Skip it. <mask> // </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove _, inputNameOnly := filepath.Split(header.Name) if inputNameOnly == "" { continue </s> add break </s> remove if header.Typeflag == tar.TypeDir { if inputNameOnly == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): This whole package needs to // be rewritten and covered in more integration // tests. It has weird assumptions and file // mode issues. continue } </s> add if name != "" { files = append(files, name) } } </s> remove fi := zf.FileInfo() inputNameOnly := fi.Name() if inputNameOnly == "" { continue } outputName := filepath.Join(outdir, inputNameOnly) if fi.IsDir() { if inputNameOnly == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. continue } err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) break } log.Tracef("created directory %q", outputName) continue } var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) if err != nil { err2 = fmt.Errorf("os.OpenFile(): %w", err) break } _, err = io.Copy(f, zr) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break </s> add if name != "" { files = append(files, name) </s> remove continue } else if header.Typeflag != tar.TypeReg { log.Debug("updater: %s: unknown file type %d, skipping", inputNameOnly, header.Typeflag) continue </s> add outputName := filepath.Join(outDir, name) if fi.IsDir() { if name == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. return "", nil </s> remove } </s> add } else if err != nil { err = fmt.Errorf("tarReader.Next(): %w", err)
[ "keep", "keep", "keep", "keep", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
if name != "" { files = append(files, name) } }
<mask> } <mask> <mask> outputName := filepath.Join(outdir, inputNameOnly) <mask> <mask> if header.Typeflag == tar.TypeDir { <mask> if inputNameOnly == "AdGuardHome" { <mask> // Top-level AdGuardHome/. Skip it. <mask> // <mask> // TODO(a.garipov): This whole package needs to <mask> // be rewritten and covered in more integration <mask> // tests. It has weird assumptions and file <mask> // mode issues. <mask> continue <mask> } <mask> <mask> err = os.Mkdir(outputName, os.FileMode(header.Mode&0o777)) <mask> if err != nil && !errors.Is(err, os.ErrExist) { <mask> err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) <mask> </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove outputName := filepath.Join(outdir, inputNameOnly) </s> add var name string name, err = tarGzFileUnpackOne(outDir, tarReader, hdr) </s> remove err = os.Mkdir(outputName, os.FileMode(header.Mode&0o777)) if err != nil && !errors.Is(err, os.ErrExist) { err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) </s> add return files, err } </s> remove fi := zf.FileInfo() inputNameOnly := fi.Name() if inputNameOnly == "" { continue } outputName := filepath.Join(outdir, inputNameOnly) if fi.IsDir() { if inputNameOnly == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. continue } err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) break } log.Tracef("created directory %q", outputName) continue } var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) if err != nil { err2 = fmt.Errorf("os.OpenFile(): %w", err) break } _, err = io.Copy(f, zr) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break </s> add if name != "" { files = append(files, name) </s> remove _, inputNameOnly := filepath.Split(header.Name) if inputNameOnly == "" { continue </s> add break </s> remove continue } else if header.Typeflag != tar.TypeReg { log.Debug("updater: %s: unknown file type %d, skipping", inputNameOnly, header.Typeflag) continue </s> add outputName := filepath.Join(outDir, name) if fi.IsDir() { if name == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. return "", nil
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
return files, err }
<mask> // mode issues. <mask> continue <mask> } <mask> <mask> err = os.Mkdir(outputName, os.FileMode(header.Mode&0o777)) <mask> if err != nil && !errors.Is(err, os.ErrExist) { <mask> err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) <mask> <mask> break <mask> } <mask> <mask> log.Debug("updater: created directory %q", outputName) </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove break } </s> add func zipFileUnpackOne(outDir string, zf *zip.File) (name string, err error) { var rc io.ReadCloser rc, err = zf.Open() if err != nil { return "", fmt.Errorf("zip file Open(): %w", err) } defer func() { err = errors.WithDeferred(err, rc.Close()) }() </s> remove var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(header.Mode&0o777)) if err != nil { err2 = fmt.Errorf("os.OpenFile(%s): %w", outputName, err) break } _, err = io.Copy(f, tarReader) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break } err = f.Close() if err != nil { err2 = fmt.Errorf("f.Close(): %w", err) break </s> add err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { return "", fmt.Errorf("os.Mkdir(%q): %w", outputName, err) </s> remove if header.Typeflag == tar.TypeDir { if inputNameOnly == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): This whole package needs to // be rewritten and covered in more integration // tests. It has weird assumptions and file // mode issues. continue } </s> add if name != "" { files = append(files, name) } } </s> remove fi := zf.FileInfo() inputNameOnly := fi.Name() if inputNameOnly == "" { continue } outputName := filepath.Join(outdir, inputNameOnly) if fi.IsDir() { if inputNameOnly == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. continue } err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) break } log.Tracef("created directory %q", outputName) continue } var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) if err != nil { err2 = fmt.Errorf("os.OpenFile(): %w", err) break } _, err = io.Copy(f, zr) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break </s> add if name != "" { files = append(files, name) </s> remove log.Debug("updater: created file %s", outputName) files = append(files, header.Name) </s> add log.Tracef("created directory %q", outputName) return "", nil
[ "keep", "keep", "keep", "keep", "replace", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go
func zipFileUnpackOne(outDir string, zf *zip.File) (name string, err error) { var rc io.ReadCloser rc, err = zf.Open() if err != nil { return "", fmt.Errorf("zip file Open(): %w", err) } defer func() { err = errors.WithDeferred(err, rc.Close()) }()
<mask> err = os.Mkdir(outputName, os.FileMode(header.Mode&0o777)) <mask> if err != nil && !errors.Is(err, os.ErrExist) { <mask> err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) <mask> <mask> break <mask> } <mask> <mask> log.Debug("updater: created directory %q", outputName) <mask> <mask> continue <mask> } else if header.Typeflag != tar.TypeReg { </s> Pull request: replace agherr with golibs' errors Merge in DNS/adguard-home from golibs-errors to master Squashed commit of the following: commit 5aba278a31c5a213bd9e08273ce7277c57713b22 Author: Ainar Garipov <[email protected]> Date: Mon May 24 17:05:18 2021 +0300 all: imp code commit f447eb875b81779fa9e391d98c31c1eeba7ef323 Author: Ainar Garipov <[email protected]> Date: Mon May 24 15:33:45 2021 +0300 replace agherr with golibs' errors </s> remove err = os.Mkdir(outputName, os.FileMode(header.Mode&0o777)) if err != nil && !errors.Is(err, os.ErrExist) { err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) </s> add return files, err } </s> remove var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.FileMode(header.Mode&0o777)) if err != nil { err2 = fmt.Errorf("os.OpenFile(%s): %w", outputName, err) break } _, err = io.Copy(f, tarReader) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break } err = f.Close() if err != nil { err2 = fmt.Errorf("f.Close(): %w", err) break </s> add err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { return "", fmt.Errorf("os.Mkdir(%q): %w", outputName, err) </s> remove log.Debug("updater: created directory %q", outputName) </s> add fi := zf.FileInfo() name = fi.Name() if name == "" { return "", nil } </s> remove fi := zf.FileInfo() inputNameOnly := fi.Name() if inputNameOnly == "" { continue } outputName := filepath.Join(outdir, inputNameOnly) if fi.IsDir() { if inputNameOnly == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. continue } err = os.Mkdir(outputName, fi.Mode()) if err != nil && !errors.Is(err, os.ErrExist) { err2 = fmt.Errorf("os.Mkdir(%q): %w", outputName, err) break } log.Tracef("created directory %q", outputName) continue } var f io.WriteCloser f, err = os.OpenFile(outputName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, fi.Mode()) if err != nil { err2 = fmt.Errorf("os.OpenFile(): %w", err) break } _, err = io.Copy(f, zr) if err != nil { _ = f.Close() err2 = fmt.Errorf("io.Copy(): %w", err) break </s> add if name != "" { files = append(files, name) </s> remove continue } else if header.Typeflag != tar.TypeReg { log.Debug("updater: %s: unknown file type %d, skipping", inputNameOnly, header.Typeflag) continue </s> add outputName := filepath.Join(outDir, name) if fi.IsDir() { if name == "AdGuardHome" { // Top-level AdGuardHome/. Skip it. // // TODO(a.garipov): See the similar todo in // tarGzFileUnpack. return "", nil
[ "keep", "keep", "keep", "keep", "replace", "replace", "keep", "keep", "keep", "keep", "keep" ]
https://github.com/AdguardTeam/AdGuardHome/commit/03a828ef5140f232ee755f62d9c3410242833b38
internal/updater/updater.go