Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-12-19 14:17:44 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-12-19 20:51:59 +0300
commitad6504e6b504277bbc7b60d093cdccd4f3baaa4f (patch)
tree294ef0155dcd9b884fa387512b2b54ab0ef1493e /modules/collect.go
parent158e7ec204e5149d77893d353cac9f55946d3e9a (diff)
Fix abs path handling in module mounts
Fixes #6622
Diffstat (limited to 'modules/collect.go')
-rw-r--r--modules/collect.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/modules/collect.go b/modules/collect.go
index de71b50a6..0ac766fb9 100644
--- a/modules/collect.go
+++ b/modules/collect.go
@@ -548,7 +548,7 @@ func (c *collector) loadModules() error {
return nil
}
-func (c *collector) normalizeMounts(owner Module, mounts []Mount) ([]Mount, error) {
+func (c *collector) normalizeMounts(owner *moduleAdapter, mounts []Mount) ([]Mount, error) {
var out []Mount
dir := owner.Dir()
@@ -562,8 +562,16 @@ func (c *collector) normalizeMounts(owner Module, mounts []Mount) ([]Mount, erro
mnt.Source = filepath.Clean(mnt.Source)
mnt.Target = filepath.Clean(mnt.Target)
+ var sourceDir string
+
+ if owner.projectMod && filepath.IsAbs(mnt.Source) {
+ // Abs paths in the main project is allowed.
+ sourceDir = mnt.Source
+ } else {
+ sourceDir = filepath.Join(dir, mnt.Source)
+ }
+
// Verify that Source exists
- sourceDir := filepath.Join(dir, mnt.Source)
_, err := c.fs.Stat(sourceDir)
if err != nil {
continue