Skip to content

Commit

Permalink
cmd/covergen: Switched from zglob to filepath.Walk (closes #49)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgaskin committed Jun 24, 2020
1 parent 888158c commit 00da6b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
13 changes: 11 additions & 2 deletions cmd/covergen/covergen.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/bamiaux/rez"
"github.com/beevik/etree"
"github.com/geek1011/koboutils/v2/kobo"
"github.com/mattn/go-zglob"
"github.com/spf13/pflag"
)

Expand Down Expand Up @@ -204,7 +203,17 @@ func device(root string) (string, kobo.Device, error) {
}

func scan(root string) ([]string, error) {
return zglob.Glob(filepath.Join(root, "**", "*.epub"))
var epubs []string
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return fmt.Errorf("error scanning %q: %w", path, err)
}
if !info.IsDir() && strings.EqualFold(filepath.Ext(path), ".epub") {
epubs = append(epubs, path)
}
return nil
})
return epubs, err
}

func imageID(kp, book string) (string, error) {
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/bamiaux/rez v0.0.0-20170731184118-29f4463c688b
github.com/geek1011/koboutils/v2 v2.0.1
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/mattn/go-zglob v0.0.1
github.com/spf13/pflag v1.0.5
)

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-zglob v0.0.1 h1:xsEx/XUoVlI6yXjqBK062zYhRTZltCNmYPx6v+8DNaY=
github.com/mattn/go-zglob v0.0.1/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
Expand Down

0 comments on commit 00da6b2

Please sign in to comment.