diff options
author | Bjørn Erik Pedersen <[email protected]> | 2022-03-20 11:24:44 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-03-20 20:23:03 +0100 |
commit | 1c0e7c1ae1eb9cd47fbe030ebddbf89df04fe667 (patch) | |
tree | e3e5528048ddb5bb749e7549eb8946717ebd45a3 /hugofs | |
parent | cad2d8cc70f25ca5e5107dd963c95b7b7c6840d1 (diff) | |
download | hugo-1c0e7c1ae1eb9cd47fbe030ebddbf89df04fe667.tar.gz hugo-1c0e7c1ae1eb9cd47fbe030ebddbf89df04fe667.zip |
Make sure file mounts higher up wins
Fixes #9693
Diffstat (limited to 'hugofs')
-rw-r--r-- | hugofs/fileinfo.go | 1 | ||||
-rw-r--r-- | hugofs/filter_fs.go | 4 | ||||
-rw-r--r-- | hugofs/language_composite_fs.go | 37 | ||||
-rw-r--r-- | hugofs/walk.go | 7 |
4 files changed, 14 insertions, 35 deletions
diff --git a/hugofs/fileinfo.go b/hugofs/fileinfo.go index 40955545a..29ac3c240 100644 --- a/hugofs/fileinfo.go +++ b/hugofs/fileinfo.go @@ -60,7 +60,6 @@ type FileMeta struct { Module string Weight int - Ordinal int IsOrdered bool IsSymlink bool IsRootFile bool diff --git a/hugofs/filter_fs.go b/hugofs/filter_fs.go index 9da63bbb7..ec3897d9e 100644 --- a/hugofs/filter_fs.go +++ b/hugofs/filter_fs.go @@ -47,10 +47,9 @@ func NewLanguageFs(langs map[string]int, fs afero.Fs) (afero.Fs, error) { lang := meta.Lang fileLang, translationBaseName, translationBaseNameWithExt := langInfoFrom(langs, fi.Name()) - weight := 0 + weight := meta.Weight if fileLang != "" { - weight = 1 if fileLang == lang { // Give priority to myfile.sv.txt inside the sv filesystem. weight++ @@ -63,7 +62,6 @@ func NewLanguageFs(langs map[string]int, fs afero.Fs) (afero.Fs, error) { &FileMeta{ Lang: lang, Weight: weight, - Ordinal: langs[lang], TranslationBaseName: translationBaseName, TranslationBaseNameWithExt: translationBaseNameWithExt, Classifier: files.ClassifyContentFile(fi.Name(), meta.OpenFunc), diff --git a/hugofs/language_composite_fs.go b/hugofs/language_composite_fs.go index 09c4540a9..65bc89e71 100644 --- a/hugofs/language_composite_fs.go +++ b/hugofs/language_composite_fs.go @@ -15,7 +15,6 @@ package hugofs import ( "os" - "path" "github.com/spf13/afero" ) @@ -56,32 +55,20 @@ func (fs *languageCompositeFs) Open(name string) (afero.File, error) { // LanguageDirsMerger implements the afero.DirsMerger interface, which is used // to merge two directories. var LanguageDirsMerger = func(lofi, bofi []os.FileInfo) ([]os.FileInfo, error) { - m := make(map[string]FileMetaInfo) - - getKey := func(fim FileMetaInfo) string { - return path.Join(fim.Meta().Lang, fim.Name()) - } - - for _, fi := range lofi { - fim := fi.(FileMetaInfo) - m[getKey(fim)] = fim - } - - for _, fi := range bofi { - fim := fi.(FileMetaInfo) - key := getKey(fim) - _, found := m[key] + for _, fi1 := range bofi { + fim1 := fi1.(FileMetaInfo) + var found bool + for _, fi2 := range lofi { + fim2 := fi2.(FileMetaInfo) + if fi1.Name() == fi2.Name() && fim1.Meta().Lang == fim2.Meta().Lang { + found = true + break + } + } if !found { - m[key] = fim + lofi = append(lofi, fi1) } } - merged := make([]os.FileInfo, len(m)) - i := 0 - for _, v := range m { - merged[i] = v - i++ - } - - return merged, nil + return lofi, nil } diff --git a/hugofs/walk.go b/hugofs/walk.go index c02d36671..26f1b74e0 100644 --- a/hugofs/walk.go +++ b/hugofs/walk.go @@ -224,13 +224,8 @@ func (w *Walkway) walk(path string, info FileMetaInfo, dirEntries []FileMetaInfo // to the closest one. fiw, fjw := fim.Weight, fjm.Weight if fiw != fjw { - return fiw > fjw - } - // Explicit order set. - fio, fjo := fim.Ordinal, fjm.Ordinal - if fio != fjo { - return fio < fjo + return fiw > fjw } // When we walk into a symlink, we keep the reference to |