Skip to content

Commit

Permalink
Fixed panic when calling os.Stat in gpath library
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide bonomini committed Oct 21, 2024
1 parent aac45d1 commit d12cfbc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/gpath/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ func RSlash(path string) string {
// IsDirExist checks if is directory exist
func IsDirExist(path string) bool {
info, err := os.Stat(path)
if os.IsNotExist(err) || info == nil {
if err != nil {
if os.IsNotExist(err) || info == nil {
return false
}
log.Error("Unable to access fs:", err.Error())
return false
}
return info.IsDir()
Expand All @@ -60,7 +64,11 @@ func IsDir(path string) bool {
// IsFileExist checks if file exist
func IsFileExist(path string) bool {
info, err := os.Stat(path)
if os.IsNotExist(err) {
if err != nil {
if os.IsNotExist(err) {
return false
}
log.Error("Unable to access fs:", err.Error())
return false
}
return !info.IsDir()
Expand Down

0 comments on commit d12cfbc

Please sign in to comment.