aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/filesystems/basefs.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-07-31 08:21:17 +0200
committerBjørn Erik Pedersen <[email protected]>2019-07-31 12:10:05 +0200
commit4b6c5eba306e6e69f3dd07a6c102bfc8040b38c9 (patch)
treecf12d586dc4fc0937900b96b81e10a852eeeba6f /hugolib/filesystems/basefs.go
parentedf9f0a354e5eaa556f8faed70b5243b7273b35c (diff)
downloadhugo-4b6c5eba306e6e69f3dd07a6c102bfc8040b38c9.tar.gz
hugo-4b6c5eba306e6e69f3dd07a6c102bfc8040b38c9.zip
Move the mount duplicate filter to the modules package
Also simplify the mount validation logic. There are plenty of ways a user can create mount configs that behaves oddly.
Diffstat (limited to 'hugolib/filesystems/basefs.go')
-rw-r--r--hugolib/filesystems/basefs.go42
1 files changed, 4 insertions, 38 deletions
diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go
index 57d9d158b..e550d7f35 100644
--- a/hugolib/filesystems/basefs.go
+++ b/hugolib/filesystems/basefs.go
@@ -18,7 +18,6 @@ package filesystems
import (
"io"
"os"
- "path"
"path/filepath"
"strings"
"sync"
@@ -454,7 +453,6 @@ func (b *sourceFilesystemsBuilder) createMainOverlayFs(p *paths.Paths) (*filesys
// The theme components are ordered from left to right.
// We need to revert it to get the
// overlay logic below working as expected, with the project on top (last).
-
for i, mod := range mods {
dir := mod.Dir()
@@ -463,11 +461,9 @@ func (b *sourceFilesystemsBuilder) createMainOverlayFs(p *paths.Paths) (*filesys
}
isMainProject := mod.Owner() == nil
- // TODO(bep) embed mount + move any duplicate/overlap
modsReversed[i] = mountsDescriptor{
- mounts: mod.Mounts(),
+ Module: mod,
dir: dir,
- watch: mod.Watch(),
isMainProject: isMainProject,
}
}
@@ -500,36 +496,7 @@ func (b *sourceFilesystemsBuilder) createModFs(
return paths.AbsPathify(md.dir, path)
}
- seen := make(map[string]bool)
-
- var mounts []modules.Mount
-
-OUTER:
- for i, mount := range md.mounts {
- key := path.Join(mount.Lang, mount.Source, mount.Target)
- if seen[key] {
- continue
- }
- seen[key] = true
-
- // Prevent overlapping mounts
- for j, mount2 := range md.mounts {
- if j == i || mount2.Target != mount.Target {
- continue
- }
- source := mount.Source
- if !strings.HasSuffix(source, filePathSeparator) {
- source += filePathSeparator
- }
- if strings.HasPrefix(mount2.Source, source) {
- continue OUTER
- }
- }
-
- mounts = append(mounts, mount)
- }
-
- for _, mount := range mounts {
+ for _, mount := range md.Mounts() {
mountWeight := 1
if md.isMainProject {
@@ -540,7 +507,7 @@ OUTER:
From: mount.Target,
To: absPathify(mount.Source),
Meta: hugofs.FileMeta{
- "watch": md.watch,
+ "watch": md.Watch(),
"mountWeight": mountWeight,
},
}
@@ -703,9 +670,8 @@ func (c *filesystemsCollector) reverseFis(fis []hugofs.FileMetaInfo) {
}
type mountsDescriptor struct {
- mounts []modules.Mount
+ modules.Module
dir string
- watch bool // whether this is a candidate for watching in server mode.
isMainProject bool
}