Better handling of os.Stat() errors (#1173)
This commit is contained in:
parent
7361578412
commit
08b6c4e3cf
@ -22,15 +22,16 @@ import (
|
||||
|
||||
// DoesFileExists checks if the file exists.
|
||||
func DoesFileExists(name string) bool {
|
||||
if _, err := os.Stat(name); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
if _, err := os.Stat(name); err == nil {
|
||||
return true
|
||||
} else if os.IsNotExist(err) {
|
||||
return false
|
||||
} else {
|
||||
log.Errorln(err)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// GetRelativePathFromAbsolutePath gets the relative path from the provided absolute path.
|
||||
func GetRelativePathFromAbsolutePath(path string) string {
|
||||
pathComponents := strings.Split(path, "/")
|
||||
|
Loading…
Reference in New Issue
Block a user