Only touch lock files after successful JSON writes
AtomicWriteFile truly is atomic, it only changes the file on success. So there's no point notifying other processes about a changed file if we failed, they are going to see the same JSON data. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
fb2df5d9fd
commit
a02dbdbfa1
|
|
@ -243,8 +243,10 @@ func (r *containerStore) Save() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer r.Touch()
|
if err := ioutils.AtomicWriteFile(rpath, jdata, 0600); err != nil {
|
||||||
return ioutils.AtomicWriteFile(rpath, jdata, 0600)
|
return err
|
||||||
|
}
|
||||||
|
return r.Touch()
|
||||||
}
|
}
|
||||||
|
|
||||||
func newContainerStore(dir string) (ContainerStore, error) {
|
func newContainerStore(dir string) (ContainerStore, error) {
|
||||||
|
|
|
||||||
|
|
@ -324,8 +324,10 @@ func (r *imageStore) Save() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer r.Touch()
|
if err := ioutils.AtomicWriteFile(rpath, jdata, 0600); err != nil {
|
||||||
return ioutils.AtomicWriteFile(rpath, jdata, 0600)
|
return err
|
||||||
|
}
|
||||||
|
return r.Touch()
|
||||||
}
|
}
|
||||||
|
|
||||||
func newImageStore(dir string) (ImageStore, error) {
|
func newImageStore(dir string) (ImageStore, error) {
|
||||||
|
|
|
||||||
|
|
@ -501,8 +501,10 @@ func (r *layerStore) saveLayers() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer r.Touch()
|
if err := ioutils.AtomicWriteFile(rpath, jldata, 0600); err != nil {
|
||||||
return ioutils.AtomicWriteFile(rpath, jldata, 0600)
|
return err
|
||||||
|
}
|
||||||
|
return r.Touch()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *layerStore) saveMounts() error {
|
func (r *layerStore) saveMounts() error {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue