common: simplify FileExist helper (#32969)
Some checks are pending
/ Docker Image (push) Waiting to run
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run

This commit is contained in:
Coder 2025-10-30 02:20:07 +01:00 committed by GitHub
parent 5dd0fe2f53
commit ccacbd1e37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,6 +17,8 @@
package common
import (
"errors"
"io/fs"
"os"
"path/filepath"
)
@ -24,10 +26,7 @@ import (
// FileExist checks if a file exists at filePath.
func FileExist(filePath string) bool {
_, err := os.Stat(filePath)
if err != nil && os.IsNotExist(err) {
return false
}
return true
return !errors.Is(err, fs.ErrNotExist)
}
// AbsolutePath returns datadir + filename, or filename if it is absolute.