Skip to content

Commit

Permalink
all: fix build, imp err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed May 19, 2021
1 parent 6868eac commit 9bb32bc
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 13 deletions.
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
#
# See https://stackoverflow.com/a/7335487/1892060.
#
# Only build, run, and test outputs here. Sorted.
# Only build, run, and test outputs here. Sorted. With negations at the
# bottom to make sure they take effect.
*.db
*.log
*.snap
/bin/
/build/
/build2/
/build/*
/build2/*
/data/
/dist/
/dnsfilter/tests/dnsfilter.TestLotsOfRules*.pprof
Expand All @@ -22,3 +23,6 @@ AdGuardHome*
coverage.txt
leases.db
node_modules/

!/build/gitkeep
!/build2/gitkeep
1 change: 1 addition & 0 deletions build/gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Keep this file non-hidden for Go's embedding to work.
1 change: 1 addition & 0 deletions build2/gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Keep this file non-hidden for Go's embedding to work.
4 changes: 2 additions & 2 deletions internal/dnsfilter/dnsfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,14 +587,14 @@ func createFilteringEngine(filters []Filter) (*filterlist.RuleStorage, *urlfilte
// used.
data, err := os.ReadFile(f.FilePath)
if err != nil {
return nil, nil, fmt.Errorf("os.ReadFile(): %s: %w", f.FilePath, err)
return nil, nil, fmt.Errorf("reading filter content: %w", err)
}

list = &filterlist.StringRuleList{
ID: int(f.ID),
RulesText: string(data),
IgnoreCosmetic: true,
}

} else {
var err error
list, err = filterlist.NewFileRuleList(int(f.ID), f.FilePath, true)
Expand Down
9 changes: 6 additions & 3 deletions internal/home/authglinet.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func glGetTokenDate(file string) uint32 {

fileReadCloser, err := aghio.LimitReadCloser(f, MaxFileSize)
if err != nil {
log.Error("LimitReadCloser: %s", err)
log.Error("creating limited reader: %s", err)

return 0
}
defer fileReadCloser.Close()
Expand All @@ -89,14 +90,16 @@ func glGetTokenDate(file string) uint32 {
// This use of ReadAll is now safe, because we limited reader.
bs, err := io.ReadAll(fileReadCloser)
if err != nil {
log.Error("io.ReadAll: %s", err)
log.Error("reading token: %s", err)

return 0
}

buf := bytes.NewBuffer(bs)

err = binary.Read(buf, aghos.NativeEndian, &dateToken)
if err != nil {
log.Error("binary.Read: %s", err)
log.Error("decoding token: %s", err)

return 0
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/AdguardTeam/AdGuardHome/internal/home"
)

//go:embed build/static build2/static
//go:embed build build2
var clientBuildFS embed.FS

func main() {
Expand Down
11 changes: 7 additions & 4 deletions scripts/make/clean.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

verbose="${VERBOSE:-0}"
readonly verbose

if [ "$verbose" -gt '0' ]
then
Expand All @@ -11,17 +12,19 @@ set -e -f -u

dist_dir="$DIST_DIR"
go="${GO:-go}"
sudo_cmd="${SUDO:-}"
readonly dist_dir go sudo_cmd

rm -f\
$sudo_cmd rm -f\
./AdGuardHome\
./AdGuardHome.exe\
./coverage.txt\
;

rm -f -r\
$sudo_cmd rm -f -r\
./bin/\
./build/\
./build2/\
./build/static/\
./build2/static/\
./client/node_modules/\
./client2/node_modules/\
./data/\
Expand Down

0 comments on commit 9bb32bc

Please sign in to comment.