mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-25 22:00:58 +02:00
@@ -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
|
||||
|
Reference in New Issue
Block a user