"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "hugofs/decorators.go" between
hugo-0.85.0.tar.gz and hugo-0.86.0.tar.gz

About: Hugo is a static site generator that takes a source directory of Markdown files and templates and uses these as input to create a complete website (written in Go).

decorators.go  (hugo-0.85.0):decorators.go  (hugo-0.86.0)
skipping to change at line 26 skipping to change at line 26
import ( import (
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/spf13/afero" "github.com/spf13/afero"
) )
func decorateDirs(fs afero.Fs, meta FileMeta) afero.Fs { func decorateDirs(fs afero.Fs, meta *FileMeta) afero.Fs {
ffs := &baseFileDecoratorFs{Fs: fs} ffs := &baseFileDecoratorFs{Fs: fs}
decorator := func(fi os.FileInfo, name string) (os.FileInfo, error) { decorator := func(fi os.FileInfo, name string) (os.FileInfo, error) {
if !fi.IsDir() { if !fi.IsDir() {
// Leave regular files as they are. // Leave regular files as they are.
return fi, nil return fi, nil
} }
return decorateFileInfo(fi, fs, nil, "", "", meta), nil return decorateFileInfo(fi, fs, nil, "", "", meta), nil
} }
skipping to change at line 85 skipping to change at line 85
return ffs return ffs
} }
// NewBaseFileDecorator decorates the given Fs to provide the real filename // NewBaseFileDecorator decorates the given Fs to provide the real filename
// and an Opener func. // and an Opener func.
func NewBaseFileDecorator(fs afero.Fs, callbacks ...func(fi FileMetaInfo)) afero .Fs { func NewBaseFileDecorator(fs afero.Fs, callbacks ...func(fi FileMetaInfo)) afero .Fs {
ffs := &baseFileDecoratorFs{Fs: fs} ffs := &baseFileDecoratorFs{Fs: fs}
decorator := func(fi os.FileInfo, filename string) (os.FileInfo, error) { decorator := func(fi os.FileInfo, filename string) (os.FileInfo, error) {
// Store away the original in case it's a symlink. // Store away the original in case it's a symlink.
meta := FileMeta{metaKeyName: fi.Name()} meta := NewFileMeta()
meta.Name = fi.Name()
if fi.IsDir() { if fi.IsDir() {
meta[metaKeyJoinStat] = func(name string) (FileMetaInfo, error) { meta.JoinStatFunc = func(name string) (FileMetaInfo, erro r) {
joinedFilename := filepath.Join(filename, name) joinedFilename := filepath.Join(filename, name)
fi, _, err := lstatIfPossible(fs, joinedFilename) fi, _, err := lstatIfPossible(fs, joinedFilename)
if err != nil { if err != nil {
return nil, err return nil, err
} }
fi, err = ffs.decorate(fi, joinedFilename) fi, err = ffs.decorate(fi, joinedFilename)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return fi.(FileMetaInfo), nil return fi.(FileMetaInfo), nil
} }
} }
isSymlink := isSymlink(fi) isSymlink := isSymlink(fi)
if isSymlink { if isSymlink {
meta[metaKeyOriginalFilename] = filename meta.OriginalFilename = filename
var link string var link string
var err error var err error
link, fi, err = evalSymlinks(fs, filename) link, fi, err = evalSymlinks(fs, filename)
if err != nil { if err != nil {
return nil, err return nil, err
} }
filename = link filename = link
meta[metaKeyIsSymlink] = true meta.IsSymlink = true
} }
opener := func() (afero.File, error) { opener := func() (afero.File, error) {
return ffs.open(filename) return ffs.open(filename)
} }
fim := decorateFileInfo(fi, ffs, opener, filename, "", meta) fim := decorateFileInfo(fi, ffs, opener, filename, "", meta)
for _, cb := range callbacks { for _, cb := range callbacks {
cb(fim) cb(fim)
 End of changes. 5 change blocks. 
5 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)