mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 01:13:08 +00:00
Simplify error handling for static content
This commit is contained in:
parent
05fc173260
commit
9a83a0094d
10
main.go
10
main.go
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue