From 9ca93b641f8f7c78fc6ef7e97659f72eba518956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Fri, 30 Sep 2022 23:37:15 +0200 Subject: [PATCH] r.mountsLockfile.Touch() directly in saveMounts() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... 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č --- layers.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/layers.go b/layers.go index c2f1ca748..4261cd12d 100644 --- a/layers.go +++ b/layers.go @@ -479,7 +479,6 @@ func (r *layerStore) loadMounts() error { func (r *layerStore) Save() error { r.mountsLockfile.Lock() defer r.mountsLockfile.Unlock() - defer r.mountsLockfile.Touch() if err := r.saveLayers(); err != nil { return err } @@ -535,6 +534,9 @@ func (r *layerStore) saveMounts() error { if err = ioutils.AtomicWriteFile(mpath, jmdata, 0600); err != nil { return err } + if err := r.mountsLockfile.Touch(); err != nil { + return err + } return r.loadMounts() } @@ -953,7 +955,6 @@ func (r *layerStore) Mount(id string, options drivers.MountOpts) (string, error) return "", err } } - defer r.mountsLockfile.Touch() layer, ok := r.lookup(id) if !ok { return "", ErrLayerUnknown @@ -1004,7 +1005,6 @@ func (r *layerStore) Unmount(id string, force bool) (bool, error) { return false, err } } - defer r.mountsLockfile.Touch() layer, ok := r.lookup(id) if !ok { layerByMount, ok := r.bymount[filepath.Clean(id)]