diff options
Diffstat (limited to 'cmd/booktopipeline/main.go')
-rw-r--r-- | cmd/booktopipeline/main.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cmd/booktopipeline/main.go b/cmd/booktopipeline/main.go index 9d4e55f..62e4132 100644 --- a/cmd/booktopipeline/main.go +++ b/cmd/booktopipeline/main.go @@ -9,6 +9,9 @@ package main import ( "flag" "fmt" + "image" + _ "image/png" + _ "image/jpeg" "log" "os" "path/filepath" @@ -126,6 +129,27 @@ func main() { qid = conn.PreQueueId() } + verboselog.Println("Checking that all images are valid in", bookdir) + checker := make(fileWalk) + go func() { + err = filepath.Walk(bookdir, checker.Walk) + if err != nil { + log.Fatalln("Filesystem walk failed:", err) + } + close(checker) + }() + + for path := range checker { + f, err := os.Open(path) + if err != nil { + log.Fatalln("Opening image %s failed, bailing: %v", path, err) + } + _, _, err = image.Decode(f) + if err != nil { + log.Fatalf("Decoding image %s failed, bailing: %v", path, err) + } + } + verboselog.Println("Walking", bookdir) walker := make(fileWalk) go func() { |