r.mountsLockfile.Touch() directly in saveMounts()
... instead of doing it in callers. This makes it clearer that the Touch() always happens, and it adds error handling. OTOH there might be some undocumented reason why the Touch() should happen in callers even if the saveMounts() call is not reached. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
5e8eb4c69a
commit
9ca93b641f
|
|
@ -479,7 +479,6 @@ func (r *layerStore) loadMounts() error {
|
||||||
func (r *layerStore) Save() error {
|
func (r *layerStore) Save() error {
|
||||||
r.mountsLockfile.Lock()
|
r.mountsLockfile.Lock()
|
||||||
defer r.mountsLockfile.Unlock()
|
defer r.mountsLockfile.Unlock()
|
||||||
defer r.mountsLockfile.Touch()
|
|
||||||
if err := r.saveLayers(); err != nil {
|
if err := r.saveLayers(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -535,6 +534,9 @@ func (r *layerStore) saveMounts() error {
|
||||||
if err = ioutils.AtomicWriteFile(mpath, jmdata, 0600); err != nil {
|
if err = ioutils.AtomicWriteFile(mpath, jmdata, 0600); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if err := r.mountsLockfile.Touch(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return r.loadMounts()
|
return r.loadMounts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -953,7 +955,6 @@ func (r *layerStore) Mount(id string, options drivers.MountOpts) (string, error)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defer r.mountsLockfile.Touch()
|
|
||||||
layer, ok := r.lookup(id)
|
layer, ok := r.lookup(id)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", ErrLayerUnknown
|
return "", ErrLayerUnknown
|
||||||
|
|
@ -1004,7 +1005,6 @@ func (r *layerStore) Unmount(id string, force bool) (bool, error) {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
defer r.mountsLockfile.Touch()
|
|
||||||
layer, ok := r.lookup(id)
|
layer, ok := r.lookup(id)
|
||||||
if !ok {
|
if !ok {
|
||||||
layerByMount, ok := r.bymount[filepath.Clean(id)]
|
layerByMount, ok := r.bymount[filepath.Clean(id)]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue