Backend: Assume symlinks are directories #267

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2020-03-23 20:55:23 +01:00
parent a1706a5922
commit 98abbfc94e

View file

@ -25,11 +25,17 @@ func FileExists(filename string) bool {
return err == nil && !info.IsDir() return err == nil && !info.IsDir()
} }
// PathExists returns true if path exists and is a directory. // PathExists returns true if path exists and is a directory or symlink.
func PathExists(path string) bool { func PathExists(path string) bool {
info, err := os.Stat(path) info, err := os.Stat(path)
return err == nil && info.IsDir() if err != nil {
return false
}
m := info.Mode()
return m&os.ModeDir != 0 || m&os.ModeSymlink != 0
} }
// Overwrite overwrites the file with data. Creates file if not present. // Overwrite overwrites the file with data. Creates file if not present.