traefik/pkg/provider/acme/local_store_windows.go

28 lines
473 B
Go
Raw Normal View History

2017-02-04 20:21:17 +00:00
package acme
2018-03-05 19:54:04 +00:00
import "os"
2018-04-10 08:52:04 +00:00
// CheckFile checks file content size
2017-02-04 20:21:17 +00:00
// Do not check file permissions on Windows right now
2018-04-10 08:52:04 +00:00
func CheckFile(name string) (bool, error) {
2018-03-05 19:54:04 +00:00
f, err := os.Open(name)
if err != nil {
2018-04-10 08:52:04 +00:00
if os.IsNotExist(err) {
f, err = os.Create(name)
if err != nil {
return false, err
}
2020-07-07 12:42:03 +00:00
return false, f.Chmod(0o600)
2018-04-10 08:52:04 +00:00
}
2018-03-05 19:54:04 +00:00
return false, err
}
defer f.Close()
fi, err := f.Stat()
if err != nil {
return false, err
}
return fi.Size() > 0, nil
2017-02-04 20:21:17 +00:00
}