shithub: hugo

Download patch

ref: beb32af7a29bb50f3d461d52120309980cf44688
parent: be366bfe1e9318c78f0982caa16f9a94c05a57eb
author: bep <[email protected]>
date: Wed Apr 22 14:36:07 EDT 2015

Do not fail on unknown files in /data

Fixes #1068

--- a/hugolib/datafiles_test.go
+++ b/hugolib/datafiles_test.go
@@ -75,8 +75,8 @@
 	}
 	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")
 	}
 }
 
--- a/hugolib/site.go
+++ b/hugolib/site.go
@@ -307,6 +307,10 @@
 				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 @@
 	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
 	}
 }