Close created file in ACME local store CheckFile func
This commit is contained in:
parent
cef842245c
commit
76723b1288
1 changed files with 8 additions and 7 deletions
|
@ -11,14 +11,15 @@ import (
|
||||||
// CheckFile checks file permissions and content size.
|
// CheckFile checks file permissions and content size.
|
||||||
func CheckFile(name string) (bool, error) {
|
func CheckFile(name string) (bool, error) {
|
||||||
f, err := os.Open(name)
|
f, err := os.Open(name)
|
||||||
if err != nil {
|
if err != nil && os.IsNotExist(err) {
|
||||||
if os.IsNotExist(err) {
|
nf, err := os.Create(name)
|
||||||
f, err = os.Create(name)
|
if err != nil {
|
||||||
if err != nil {
|
return false, err
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
return false, f.Chmod(0o600)
|
|
||||||
}
|
}
|
||||||
|
defer nf.Close()
|
||||||
|
return false, nf.Chmod(0o600)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
Loading…
Reference in a new issue