mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Suppress errors for symbolic links witch point to a file.
This commit is contained in:
parent
aeddaee901
commit
d2e022f2a7
3 changed files with 42 additions and 5 deletions
|
@ -300,7 +300,19 @@ func getDirList() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
|
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
|
||||||
jww.ERROR.Printf("Symbolic links not supported, skipping '%s'", path)
|
link, err := filepath.EvalSymlinks(path)
|
||||||
|
if err != nil {
|
||||||
|
jww.ERROR.Printf("Cannot read symbolic link '%s', error was: %s", path, 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'", path)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ package source
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"github.com/spf13/hugo/helpers"
|
|
||||||
jww "github.com/spf13/jwalterweatherman"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/hugo/helpers"
|
||||||
|
jww "github.com/spf13/jwalterweatherman"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Input interface {
|
type Input interface {
|
||||||
|
@ -85,7 +86,19 @@ func (f *Filesystem) captureFiles() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1222,7 +1222,19 @@ func (t *GoHtmlTemplate) loadTemplates(absPath string, prefix string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
|
if fi.Mode()&os.ModeSymlink == os.ModeSymlink {
|
||||||
jww.ERROR.Printf("Symbolic links not supported, skipping '%s'", absPath)
|
link, err := filepath.EvalSymlinks(absPath)
|
||||||
|
if err != nil {
|
||||||
|
jww.ERROR.Printf("Cannot read symbolic link '%s', error was: %s", absPath, 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'", absPath)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue