diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-03-01 14:42:56 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-03-01 17:10:13 +0100 |
commit | 2b2f2b75eff43ea3536350fa5a2c9ebbc1723ba8 (patch) | |
tree | 6606e04c1b64785beeed640da0edd8ea135e6085 /hugofs | |
parent | 0d6e593ffb65a67206caa3c3071d94694cfc2183 (diff) | |
download | hugo-2b2f2b75eff43ea3536350fa5a2c9ebbc1723ba8.tar.gz hugo-2b2f2b75eff43ea3536350fa5a2c9ebbc1723ba8.zip |
hugofs: Fix vertical mount merge issue
Fixes #12175
Diffstat (limited to 'hugofs')
-rw-r--r-- | hugofs/rootmapping_fs.go | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/hugofs/rootmapping_fs.go b/hugofs/rootmapping_fs.go index 336c8b4e7..a30498668 100644 --- a/hugofs/rootmapping_fs.go +++ b/hugofs/rootmapping_fs.go @@ -475,6 +475,11 @@ func (fs *RootMappingFs) newUnionFile(fis ...FileMetaInfo) (afero.File, error) { return fis[0].Meta().Open() } + if !fis[0].IsDir() { + // Pick the last file mount. + return fis[len(fis)-1].Meta().Open() + } + openers := make([]func() (afero.File, error), len(fis)) for i := len(fis) - 1; i >= 0; i-- { fi := fis[i] @@ -647,6 +652,28 @@ func (rfs *RootMappingFs) collectDirEntries(prefix string) ([]iofs.DirEntry, err } func (fs *RootMappingFs) doStat(name string) ([]FileMetaInfo, error) { + fis, err := fs.doDoStat(name) + if err != nil { + return nil, err + } + // Sanity check. Check that all is either file or directories. + var isDir, isFile bool + for _, fi := range fis { + if fi.IsDir() { + isDir = true + } else { + isFile = true + } + } + if isDir && isFile { + // For now. + return nil, os.ErrNotExist + } + + return fis, nil +} + +func (fs *RootMappingFs) doDoStat(name string) ([]FileMetaInfo, error) { name = fs.cleanName(name) key := filepathSeparator + name @@ -669,7 +696,6 @@ func (fs *RootMappingFs) doStat(name string) ([]FileMetaInfo, error) { var fis []FileMetaInfo for _, rm := range roots { - var fi FileMetaInfo fi, err = fs.statRoot(rm, name) if err == nil { |