Skip to content
Permalink
Browse files

Fix module mount in sub folder

This addresses a specific issue, but is a also a major simplification of the filesystem file mounts.

Fixes #6730
  • Loading branch information
bep committed Jan 31, 2020
1 parent 2997310 commit 80dd6ddde27ce36f5432fb780e94d4974b5277c7
@@ -79,7 +79,7 @@ func DecorateBasePathFs(base *afero.BasePathFs) afero.Fs {
}

// NewBaseFileDecorator decorates the given Fs to provide the real filename
// and an Opener func. If
// and an Opener func.
func NewBaseFileDecorator(fs afero.Fs) afero.Fs {

ffs := &baseFileDecoratorFs{Fs: fs}
@@ -102,7 +102,6 @@ func NewBaseFileDecorator(fs afero.Fs) afero.Fs {

opener := func() (afero.File, error) {
return ffs.open(filename)

}

return decorateFileInfo(fi, ffs, opener, filename, "", meta), nil
@@ -18,6 +18,7 @@ import (
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"time"

@@ -271,13 +272,21 @@ func (fi *dirNameOnlyFileInfo) Sys() interface{} {
return nil
}

func newDirNameOnlyFileInfo(name string, isOrdered bool, fileOpener func() (afero.File, error)) FileMetaInfo {
func newDirNameOnlyFileInfo(name string, meta FileMeta, isOrdered bool, fileOpener func() (afero.File, error)) FileMetaInfo {
name = normalizeFilename(name)
_, base := filepath.Split(name)
return NewFileMetaInfo(&dirNameOnlyFileInfo{name: base}, FileMeta{
metaKeyFilename: name,
metaKeyIsOrdered: isOrdered,
metaKeyOpener: fileOpener})

m := copyFileMeta(meta)
if _, found := m[metaKeyFilename]; !found {
m.setIfNotZero(metaKeyFilename, name)
}
m[metaKeyOpener] = fileOpener
m[metaKeyIsOrdered] = isOrdered

return NewFileMetaInfo(
&dirNameOnlyFileInfo{name: base},
m,
)
}

func decorateFileInfo(
@@ -339,3 +348,18 @@ func fileInfosToNames(fis []os.FileInfo) []string {
}
return names
}

func fromSlash(filenames []string) []string {
for i, name := range filenames {
filenames[i] = filepath.FromSlash(name)
}
return filenames
}

func sortFileInfos(fis []os.FileInfo) {
sort.Slice(fis, func(i, j int) bool {
fimi, fimj := fis[i].(FileMetaInfo), fis[j].(FileMetaInfo)
return fimi.Meta().Filename() < fimj.Meta().Filename()

})
}
@@ -137,6 +137,7 @@ func TestNoSymlinkFs(t *testing.T) {
c.Assert(err, qt.IsNil)
// There is at least one unsported symlink inside workDir
_, err = f.Readdir(-1)
c.Assert(err, qt.IsNil)
f.Close()
c.Assert(logger.WarnCounter.Count(), qt.Equals, uint64(1))

0 comments on commit 80dd6dd

Please sign in to comment.
You can’t perform that action at this time.