Do not fail on unknown files in /data

Fixes #1068
This commit is contained in:
bep 2015-04-22 18:36:07 +02:00
parent be366bfe1e
commit beb32af7a2
2 changed files with 8 additions and 3 deletions

View file

@ -75,8 +75,8 @@ func TestDataDirUnknownFormat(t *testing.T) {
}
s := &Site{}
err := s.loadData([]source.Input{&source.InMemorySource{ByteSource: sources}})
if err == nil {
t.Fatalf("Should return an error")
if err != nil {
t.Fatalf("Should not return an error")
}
}

View file

@ -307,6 +307,10 @@ func (s *Site) loadData(sources []source.Input) (err error) {
return fmt.Errorf("Failed to read data from %s: %s", filepath.Join(r.Path(), r.LogicalName()), err)
}
if data == nil {
continue
}
// Copy content from current to data when needed
if _, ok := current[r.BaseFileName()]; ok {
data := data.(map[string]interface{})
@ -340,7 +344,8 @@ func readData(f *source.File) (interface{}, error) {
case "toml":
return parser.HandleTOMLMetaData(f.Bytes())
default:
return nil, fmt.Errorf("Data not supported for extension '%s'", f.Extension())
jww.WARN.Printf("Data not supported for extension '%s'", f.Extension())
return nil, nil
}
}