Skip to content

Commit

Permalink
Fix duplicate mount sources
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Jan 26, 2022
1 parent 2655739 commit 75e0e2c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
3 changes: 2 additions & 1 deletion hugofs/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func (w *Walkway) walk(path string, info FileMetaInfo, dirEntries []FileMetaInfo
}

fis, err := f.Readdir(-1)

f.Close()
if err != nil {
if w.checkErr(filename, err) {
Expand Down Expand Up @@ -270,7 +271,7 @@ func (w *Walkway) walk(path string, info FileMetaInfo, dirEntries []FileMetaInfo
meta.Path = normalizeFilename(pathMeta)
meta.PathWalk = pathn

if fim.IsDir() && w.isSeen(meta.Filename) {
if fim.IsDir() && meta.IsSymlink && w.isSeen(meta.Filename) {
// Prevent infinite recursion
// Possible cyclic reference
meta.SkipDir = true
Expand Down
36 changes: 36 additions & 0 deletions hugolib/hugo_modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1134,3 +1134,39 @@ P1: {{ $p1.Title }}|{{ $p1.RelPermalink }}|Filename: {{ $p1.File.Filename }}

b.AssertFileContent("public/index.html", "P1: Abs|/p1/", "Filename: "+contentFilename)
}

// Issue 9426
func TestMountSameSource(t *testing.T) {
config := `baseURL = 'https://example.org/'
languageCode = 'en-us'
title = 'Hugo GitHub Issue #9426'
disableKinds = ['RSS','sitemap','taxonomy','term']
[[module.mounts]]
source = "content"
target = "content"
[[module.mounts]]
source = "extra-content"
target = "content/resources-a"
[[module.mounts]]
source = "extra-content"
target = "content/resources-b"
`
b := newTestSitesBuilder(t).WithConfigFile("toml", config)

b.WithContent("p1.md", "")

b.WithSourceFile(
"extra-content/_index.md", "",
"extra-content/subdir/_index.md", "",
"extra-content/subdir/about.md", "",
)

b.Build(BuildCfg{})

b.AssertFileContent("public/resources-a/subdir/about/index.html", "Single")
b.AssertFileContent("public/resources-b/subdir/about/index.html", "Single")
}
1 change: 0 additions & 1 deletion hugolib/pages_capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ func (c *pagesCollector) collectDir(dirname string, partial bool, inFilter func(
seen := make(map[string]bool)

for i, fi := range readdir {

if fi.IsDir() {
continue
}
Expand Down

0 comments on commit 75e0e2c

Please sign in to comment.