Skip to content

Commit

Permalink
cmd/covergen, cmd/seriesmeta: Don't fail on scan errors in subdirecto…
Browse files Browse the repository at this point in the history
…ries (fixes #74)
  • Loading branch information
pgaskin committed Dec 6, 2021
1 parent eeec47f commit b67a144
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cmd/covergen/covergen.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ func scan(root string) ([]string, error) {
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 path != root {
fmt.Fprintf(os.Stderr, "Warning: Failed to scan %q: %v.\n", path, err)
} else {
return fmt.Errorf("error scanning %q: %w", path, err)
}
}
if !info.IsDir() && strings.EqualFold(filepath.Ext(path), ".epub") {
epubs = append(epubs, path)
Expand Down
6 changes: 5 additions & 1 deletion cmd/seriesmeta/seriesmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ func (k *Kobo) UpdateSeries(log func(filename string, i, total int, series strin
var epubs []string
err := filepath.Walk(k.Path, func(path string, info os.FileInfo, err error) error {
if err != nil {
return fmt.Errorf("error scanning %q: %w", path, err)
if path != k.Path {
fmt.Fprintf(os.Stderr, "Warning: Failed to scan %q: %v.\n", path, err)
} else {
return fmt.Errorf("error scanning %q: %w", path, err)
}
}
if !info.IsDir() && strings.EqualFold(filepath.Ext(path), ".epub") {
epubs = append(epubs, path)
Expand Down

0 comments on commit b67a144

Please sign in to comment.