1
0

Check that fs is case-sensitive

This commit is contained in:
dump_stack() 2023-05-11 02:42:34 +00:00
parent d5ea97c532
commit e2e0dad1ad
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

41
main.go
View File

@ -11,6 +11,7 @@ import (
"os"
"os/exec"
"os/user"
"path/filepath"
"runtime/debug"
"strconv"
"time"
@ -92,6 +93,37 @@ func (lw *LevelWriter) WriteLevel(l zerolog.Level, p []byte) (n int, err error)
return len(p), nil
}
func isFsCaseInsensitive(dir string) (yes bool, err error) {
pathLowercase := filepath.Join(dir, "file")
fLowercase, err := os.Create(pathLowercase)
if err != nil {
return
}
defer fLowercase.Close()
defer os.Remove(pathLowercase)
pathUppercase := filepath.Join(dir, "FILE")
fUppercase, err := os.Create(pathUppercase)
if err != nil {
return
}
defer fUppercase.Close()
defer os.Remove(pathUppercase)
statLowercase, err := fLowercase.Stat()
if err != nil {
return
}
statUppercase, err := fUppercase.Stat()
if err != nil {
return
}
yes = os.SameFile(statLowercase, statUppercase)
return
}
var tempDirBase string
var consoleWriter, fileWriter LevelWriter
@ -163,6 +195,15 @@ func main() {
log.Debug().Msgf("%v", buildInfo.Settings)
}
path := filepath.Join(usr.HomeDir, ".out-of-tree")
yes, err := isFsCaseInsensitive(path)
if err != nil {
log.Fatal().Err(err).Msg(path)
}
if yes {
log.Warn().Msg("case-insensitive file system not supported")
}
_, err = exec.LookPath(cli.ContainerRuntime)
if err != nil {
if cli.ContainerRuntime == "podman" { // default value