hugofs: Fix mount with hole regression

Fixes #6854
This commit is contained in:
Bjørn Erik Pedersen
2020-02-09 17:58:55 +01:00
parent 18888e09bb
commit b78576fd38
4 changed files with 129 additions and 10 deletions

View File

@@ -81,12 +81,28 @@ func DecorateBasePathFs(base *afero.BasePathFs) afero.Fs {
// NewBaseFileDecorator decorates the given Fs to provide the real filename
// and an Opener func.
func NewBaseFileDecorator(fs afero.Fs) afero.Fs {
ffs := &baseFileDecoratorFs{Fs: fs}
decorator := func(fi os.FileInfo, filename string) (os.FileInfo, error) {
// Store away the original in case it's a symlink.
meta := FileMeta{metaKeyName: fi.Name()}
if fi.IsDir() {
meta[metaKeyJoinStat] = func(name string) (FileMetaInfo, error) {
joinedFilename := filepath.Join(filename, name)
fi, _, err := lstatIfPossible(fs, joinedFilename)
if err != nil {
return nil, err
}
fi, err = ffs.decorate(fi, joinedFilename)
if err != nil {
return nil, err
}
return fi.(FileMetaInfo), nil
}
}
isSymlink := isSymlink(fi)
if isSymlink {
meta[metaKeyOriginalFilename] = filename