Skip to content

Commit

Permalink
Implement Locker.Locked() for windows
Browse files Browse the repository at this point in the history
The Locked() method must be implemented so that Save() will work on
windows.

Fixes: c7ba574 ("Add lock sanity checks to Save() methods")
See: #210 (comment)
Reported-by: Miloslav Trmač <[email protected]>
Signed-off-by: Zac Medico <[email protected]>
  • Loading branch information
zmedico committed Aug 28, 2018
1 parent 9fcbb57 commit 587b6cc
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lockfile_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 587b6cc

Please sign in to comment.