From c67f45b15e414e1db41215f8ab5b68b6fef11e5c Mon Sep 17 00:00:00 2001 From: oliverpool Date: Wed, 25 Aug 2021 13:52:39 +0200 Subject: [PATCH] fix: prevent panic when static_dir does not exist --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index 39fb70c..b081099 100644 --- a/main.go +++ b/main.go @@ -88,6 +88,10 @@ func (s *Site) runTask(task *Task) error { if task.StaticDir != "" { err := copyAll(task.StaticDir, task.OutputDir) if err != nil { + if os.IsNotExist(err) { + log.Printf("static_dir '%s' does not exist\n", task.StaticDir) + return nil + } return err } } @@ -96,6 +100,9 @@ func (s *Site) runTask(task *Task) error { func copyAll(srcDir, dstDir string) error { return filepath.Walk(srcDir, func(path string, info fs.FileInfo, err error) error { + if err != nil { + return err + } if info.IsDir() { // Do nothing return nil