From 587b6cc0ffac2be1c95d49ed1b11b7e145add732 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 28 Aug 2018 11:33:47 -0700 Subject: [PATCH] Implement Locker.Locked() for windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Locked() method must be implemented so that Save() will work on windows. Fixes: c7ba5749d44a ("Add lock sanity checks to Save() methods") See: https://github.com/containers/storage/pull/210#issuecomment-416671810 Reported-by: Miloslav Trmač Signed-off-by: Zac Medico --- lockfile_windows.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lockfile_windows.go b/lockfile_windows.go index ed6c5c4b2b..77490b8513 100644 --- a/lockfile_windows.go +++ b/lockfile_windows.go @@ -9,18 +9,29 @@ import ( ) func getLockFile(path string, ro bool) (Locker, error) { - return &lockfile{}, nil + return &lockfile{locked: false}, nil } type lockfile struct { - mu sync.Mutex - file string + mu sync.Mutex + file string + locked bool } func (l *lockfile) Lock() { + l.mu.Lock() + l.locked = true } + func (l *lockfile) Unlock() { + l.locked = false + l.mu.Unlock() +} + +func (l *lockfile) Locked() bool { + return l.locked } + func (l *lockfile) Modified() (bool, error) { return false, nil }