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
This commit is contained in:
Bjørn Erik Pedersen
2020-01-31 17:15:14 +01:00
parent 2997310124
commit 80dd6ddde2
10 changed files with 510 additions and 351 deletions

View File

@@ -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()
})
}