fix: prevent panic when static_dir does not exist

This commit is contained in:
oliverpool 2021-08-25 13:52:39 +02:00 committed by adnano
parent e53cf41aa0
commit c67f45b15e

View file

@ -88,6 +88,10 @@ func (s *Site) runTask(task *Task) error {
if task.StaticDir != "" { if task.StaticDir != "" {
err := copyAll(task.StaticDir, task.OutputDir) err := copyAll(task.StaticDir, task.OutputDir)
if err != nil { if err != nil {
if os.IsNotExist(err) {
log.Printf("static_dir '%s' does not exist\n", task.StaticDir)
return nil
}
return err return err
} }
} }
@ -96,6 +100,9 @@ func (s *Site) runTask(task *Task) error {
func copyAll(srcDir, dstDir string) error { func copyAll(srcDir, dstDir string) error {
return filepath.Walk(srcDir, func(path string, info fs.FileInfo, err error) error { return filepath.Walk(srcDir, func(path string, info fs.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() { if info.IsDir() {
// Do nothing // Do nothing
return nil return nil