Simplify error handling for static content

This commit is contained in:
Adnan Maolood 2022-09-24 11:31:42 -04:00
parent 05fc173260
commit 9a83a0094d

10
main.go
View file

@ -80,11 +80,7 @@ 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("error building static_dir '%s': %s\n", task.StaticDir, err)
return nil
}
return err
return fmt.Errorf("failed to copy static content: %w", err)
}
}
return nil
@ -93,6 +89,10 @@ 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 {
if path == srcDir && info == nil {
// The source directory doesn't exist
return nil
}
return err
}
if info.IsDir() {