diff options
author | René Jochum <rene@jochums.at> | 2015-02-17 22:21:37 +0100 |
---|---|---|
committer | spf13 <steve.francia@gmail.com> | 2015-02-17 19:18:28 -0800 |
commit | d2e022f2a7c3654cd1aaf24ea9134e61cb913cec (patch) | |
tree | 07c1f0ceda7aa680600498b14b2d244fe9f9455b /source | |
parent | aeddaee901b2345ceb7837124199f26cfc405607 (diff) |
Suppress errors for symbolic links witch point to a file.
Diffstat (limited to 'source')
-rw-r--r-- | source/filesystem.go | 19 |
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 } |