aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugofs
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-10-31 11:13:14 +0100
committerBjørn Erik Pedersen <[email protected]>2019-10-31 16:11:53 +0100
commit33c474b9b3bd470670740f30c5131071ce906b22 (patch)
tree3b19224f1045c333a5c2a884be648a29f334e54e /hugofs
parented2682325aeb8fd1c8139077d14a5f6906757a4e (diff)
downloadhugo-33c474b9b3bd470670740f30c5131071ce906b22.tar.gz
hugo-33c474b9b3bd470670740f30c5131071ce906b22.zip
hugofs: Fix crash in multilingual content fs
Fixes #6463
Diffstat (limited to 'hugofs')
-rw-r--r--hugofs/rootmapping_fs.go8
-rw-r--r--hugofs/rootmapping_fs_test.go2
2 files changed, 7 insertions, 3 deletions
diff --git a/hugofs/rootmapping_fs.go b/hugofs/rootmapping_fs.go
index e5679e09b..0df49cd09 100644
--- a/hugofs/rootmapping_fs.go
+++ b/hugofs/rootmapping_fs.go
@@ -196,12 +196,12 @@ func (fs *RootMappingFs) doLstat(name string, allowMultiple bool) ([]FileMetaInf
fis []FileMetaInfo
dirs []FileMetaInfo
b bool
- fi os.FileInfo
root RootMapping
err error
)
for _, root = range roots {
+ var fi os.FileInfo
fi, b, err = fs.statRoot(root, name)
if err != nil {
if os.IsNotExist(err) {
@@ -233,12 +233,16 @@ func (fs *RootMappingFs) doLstat(name string, allowMultiple bool) ([]FileMetaInf
return fis, dirs, b, nil
}
+ if len(fis) == 0 {
+ return nil, nil, false, os.ErrNotExist
+ }
+
// Open it in this composite filesystem.
opener := func() (afero.File, error) {
return fs.Open(name)
}
- return []FileMetaInfo{decorateFileInfo(fi, fs, opener, "", "", root.Meta)}, nil, b, nil
+ return []FileMetaInfo{decorateFileInfo(fis[0], fs, opener, "", "", root.Meta)}, nil, b, nil
}
diff --git a/hugofs/rootmapping_fs_test.go b/hugofs/rootmapping_fs_test.go
index d2459167c..548224c12 100644
--- a/hugofs/rootmapping_fs_test.go
+++ b/hugofs/rootmapping_fs_test.go
@@ -209,7 +209,7 @@ func TestRootMappingFsMount(t *testing.T) {
blog, err := rfs.Stat(filepath.FromSlash("content/blog"))
c.Assert(err, qt.IsNil)
blogm := blog.(FileMetaInfo).Meta()
- c.Assert(blogm.Lang(), qt.Equals, "sv") // Last match
+ c.Assert(blogm.Lang(), qt.Equals, "no") // First match
f, err := blogm.Open()
c.Assert(err, qt.IsNil)