Do not fail on unknown files in /data
authorbep <bjorn.erik.pedersen@gmail.com>
Wed, 22 Apr 2015 16:36:07 +0000 (18:36 +0200)
committerbep <bjorn.erik.pedersen@gmail.com>
Wed, 22 Apr 2015 16:35:56 +0000 (18:35 +0200)
Fixes #1068

hugolib/datafiles_test.go
hugolib/site.go

index 00e1b2d77ae4a0792144de302e7c53bca12dbc04..84eb70bdffb1216d987ba5020a5cbd50b0e3eaac 100644 (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")
        }
 }
 
index 46c60a19457e0c2e6982208fcf6b626b2944aa76..4f7d04beaf45cf210d8dd5dd48ea24dbc29594df 100644 (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
        }
 }