mirror of
https://git.sr.ht/~adnano/kiln
synced 2024-10-30 09:23:09 +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 != "" {
|
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() {
|
||||||
|
|
Loading…
Reference in a new issue