Skip to content

Commit

Permalink
Merge pull request #279 from dell/fileStat
Browse files Browse the repository at this point in the history
Improving file stat code
  • Loading branch information
adarsh-dell authored Oct 13, 2023
2 parents 5cbcdba + 37aa4d0 commit 56417e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion core/semver/semver.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,14 @@ var goarchToUname = map[string]string{
}

func fileExists(filePath string) bool {
if _, err := os.Stat(filePath); !os.IsNotExist(err) {
_, err := os.Stat(filePath)
if err == nil {
return true
}
if os.IsNotExist(err) {
fmt.Printf("File %s doesn't exist", filePath)
} else {
fmt.Printf("Found error %v while checking stat of file %s ", err, filePath)
}
return false
}
15 changes: 13 additions & 2 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1650,8 +1650,19 @@ func (s *Service) buildInitiatorsArrayModify(initiators []string) []gopowerstore

func (s *Service) fileExists(filename string) bool {
_, err := s.Fs.Stat(filename)
if err == nil {
return true
}
if os.IsNotExist(err) {
return false
log.WithFields(log.Fields{
"filename": filename,
"error": err,
}).Error("File doesn't exist")
} else {
log.WithFields(log.Fields{
"filename": filename,
"error": err,
}).Error("Error while checking stat of file")
}
return true
return false
}

0 comments on commit 56417e3

Please sign in to comment.