ref: e6541c45ab1a3d15acd1beea73df5d17d08c7769
parent: 9f77f93071d836a35b0078d1b349968abddb4a18
author: bep <[email protected]>
date: Wed Dec 10 11:48:51 EST 2014
ERROR-log on symbolic links filepath.Walk does not follow symbolic links. There's no easy fix for that outside of Go, so the best we can do for now is to give notice to the end user by ERROR log statements. This commit also fixes a related panic situation in GenerateTemplateNameFrom when the layout dir was a symbolic link. Fixes #283
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -256,6 +256,11 @@
return nil
}
+ if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
+ jww.ERROR.Printf("Symbolic links not supported, skipping '%s'", path)
+ return nil
+ }
+
if fi.IsDir() {
a = append(a, path)
}
--- a/source/filesystem.go
+++ b/source/filesystem.go
@@ -15,13 +15,13 @@
import (
"bytes"
+ "github.com/spf13/hugo/helpers"
+ jww "github.com/spf13/jwalterweatherman"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
-
- "github.com/spf13/hugo/helpers"
)
type Input interface {
@@ -81,6 +81,11 @@
walker := func(filePath string, fi os.FileInfo, err error) error {
if err != nil {
+ return nil
+ }
+
+ if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
+ jww.ERROR.Printf("Symbolic links not supported, skipping '%s'", filePath)
return nil
}
--- a/tpl/template.go
+++ b/tpl/template.go
@@ -16,6 +16,11 @@
import (
"bytes"
"errors"
+ "github.com/eknkc/amber"
+ "github.com/spf13/cast"
+ "github.com/spf13/hugo/helpers"
+ jww "github.com/spf13/jwalterweatherman"
+ "github.com/yosssi/ace"
"html"
"html/template"
"io"
@@ -25,12 +30,6 @@
"reflect"
"strconv"
"strings"
-
- "github.com/eknkc/amber"
- "github.com/spf13/cast"
- "github.com/spf13/hugo/helpers"
- jww "github.com/spf13/jwalterweatherman"
- "github.com/yosssi/ace"
)
var localTemplates *template.Template
@@ -703,7 +702,8 @@
}
func (t *GoHtmlTemplate) GenerateTemplateNameFrom(base, path string) string {
- return filepath.ToSlash(path[len(base)+1:])
+ name, _ := filepath.Rel(base, path)
+ return filepath.ToSlash(name)
}
func ignoreDotFile(path string) bool {
@@ -713,6 +713,11 @@
func (t *GoHtmlTemplate) loadTemplates(absPath string, prefix string) {
walker := func(path string, fi os.FileInfo, err error) error {
if err != nil {
+ return nil
+ }
+
+ if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
+ jww.ERROR.Printf("Symbolic links not supported, skipping '%s'", absPath)
return nil
}