Use json.Encoder for container.toDisk
* for simmetry with fromDisk * it might be slightly better for GC because of internal sync.Pool Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
2c6351a4a5
commit
cf02b369e0
1 changed files with 10 additions and 6 deletions
|
@ -112,17 +112,21 @@ func (container *Container) fromDisk() error {
|
|||
}
|
||||
|
||||
func (container *Container) toDisk() error {
|
||||
data, err := json.Marshal(container)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pth, err := container.jsonPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ioutil.WriteFile(pth, data, 0666); err != nil {
|
||||
jsonSource, err := os.Create(pth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer jsonSource.Close()
|
||||
|
||||
enc := json.NewEncoder(jsonSource)
|
||||
|
||||
// Save container settings
|
||||
if err := enc.Encode(container); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue