aboutsummaryrefslogtreecommitdiff
path: root/internal/behavior/store.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/behavior/store.go')
-rw-r--r--internal/behavior/store.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/internal/behavior/store.go b/internal/behavior/store.go
index a558f87..4051836 100644
--- a/internal/behavior/store.go
+++ b/internal/behavior/store.go
@@ -47,12 +47,24 @@ func BuildRoomIndex(dir string) map[int]string {
func WalkYAMLDir(dir string, fn func(path, id string, data []byte) error) error {
return filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error {
- if err != nil || d.IsDir() || !strings.HasSuffix(d.Name(), ".yaml") {
+ if err != nil {
+ // A missing root is an empty tree; any other walk error (for
+ // example an unreadable directory) must surface instead of
+ // silently validating nothing.
+ if os.IsNotExist(err) {
+ return nil
+ }
+ return err
+ }
+ if d.IsDir() || !strings.HasSuffix(d.Name(), ".yaml") {
return nil
}
data, readErr := os.ReadFile(path)
if readErr != nil {
- return nil
+ if os.IsNotExist(readErr) {
+ return nil
+ }
+ return readErr
}
id := strings.TrimSuffix(d.Name(), ".yaml")
return fn(path, id, data)