Fix static sync issue with virtual mounts

Fixes #6165
This commit is contained in:
Bjørn Erik Pedersen
2019-08-09 08:09:15 +02:00
parent 8243952046
commit 166a394a2f
4 changed files with 51 additions and 1 deletions

View File

@@ -239,8 +239,14 @@ func (s SourceFilesystems) MakeStaticPathRelative(filename string) string {
// It will return an empty string if the filename is not a member of this filesystem.
func (d *SourceFilesystem) MakePathRelative(filename string) string {
for _, dir := range d.Dirs {
currentPath := dir.(hugofs.FileMetaInfo).Meta().Filename()
meta := dir.(hugofs.FileMetaInfo).Meta()
currentPath := meta.Filename()
if strings.HasPrefix(filename, currentPath) {
if path := meta.Path(); path != "" {
currentPath = strings.TrimRight(strings.TrimSuffix(currentPath, path), filePathSeparator)
}
return strings.TrimPrefix(filename, currentPath)
}
}