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:
authorRené Jochum <rene@jochums.at>2015-02-18 00:21:37 +0300
committerspf13 <steve.francia@gmail.com>2015-02-18 06:18:28 +0300
commitd2e022f2a7c3654cd1aaf24ea9134e61cb913cec (patch)
tree07c1f0ceda7aa680600498b14b2d244fe9f9455b /source/filesystem.go
parentaeddaee901b2345ceb7837124199f26cfc405607 (diff)
Suppress errors for symbolic links witch point to a file.
Diffstat (limited to 'source/filesystem.go')
-rw-r--r--source/filesystem.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/source/filesystem.go b/source/filesystem.go
index df0a4989c..597d8c7a9 100644
--- a/source/filesystem.go
+++ b/source/filesystem.go
@@ -15,13 +15,14 @@ package source
import (
"bytes"
- "github.com/spf13/hugo/helpers"
- jww "github.com/spf13/jwalterweatherman"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
+
+ "github.com/spf13/hugo/helpers"
+ jww "github.com/spf13/jwalterweatherman"
)
type Input interface {
@@ -85,7 +86,19 @@ func (f *Filesystem) captureFiles() {
}
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
- jww.ERROR.Printf("Symbolic links not supported, skipping '%s'", filePath)
+ link, err := filepath.EvalSymlinks(filePath)
+ if err != nil {
+ jww.ERROR.Printf("Cannot read symbolic link '%s', error was: %s", filePath, err)
+ return nil
+ }
+ linkfi, err := os.Stat(link)
+ if err != nil {
+ jww.ERROR.Printf("Cannot stat '%s', error was: %s", link, err)
+ return nil
+ }
+ if !linkfi.Mode().IsRegular() {
+ jww.ERROR.Printf("Symbolic links for directories not supported, skipping '%s'", filePath)
+ }
return nil
}