Simplify error handling for static content

This commit is contained in:
adnano 2022-09-24 11:31:42 -04:00
parent d1104cc712
commit 7b679a2e84

10
main.go
View file

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