mirror of
https://github.com/minio/minio.git
synced 2025-11-07 04:42:56 -05:00
Move atomic file writes into its own package, use them inside quick and disk packages
This commit is contained in:
@@ -31,6 +31,7 @@ import (
|
||||
|
||||
"github.com/fatih/structs"
|
||||
"github.com/minio/minio/pkg/iodine"
|
||||
"github.com/minio/minio/pkg/utils/atomic"
|
||||
)
|
||||
|
||||
// Config - generic config interface functions
|
||||
@@ -115,11 +116,10 @@ func (d config) Save(filename string) (err error) {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
|
||||
file, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
||||
file, err := atomic.FileCreate(filename)
|
||||
if err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
jsonData = []byte(strings.Replace(string(jsonData), "\n", "\r\n", -1))
|
||||
@@ -128,6 +128,10 @@ func (d config) Save(filename string) (err error) {
|
||||
if err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
|
||||
if err := file.Close(); err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user