pkg/lockfile: wrap error in openLock
unix.Open returns a bare error (like EPERM). This is worked around in on user, (*lockfile).lock, where we panic, but not in the other user, createLockerForPath, and as a result such a bare error might be returned from GetLockfile or GetROLockfile. Wrap it into os.PathError and remove the workaround from lockfile.lock. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
463d50fabc
commit
7d52f1732b
|
|
@ -89,7 +89,7 @@ func openLock(path string, ro bool) (fd int, err error) {
|
|||
return openLock(path, ro)
|
||||
}
|
||||
|
||||
return
|
||||
return fd, &os.PathError{Op: "open", Path: path, Err: err}
|
||||
}
|
||||
|
||||
// createLockerForPath returns a Locker object, possibly (depending on the platform)
|
||||
|
|
@ -156,7 +156,7 @@ func (l *lockfile) lock(lType int16, recursive bool) {
|
|||
// If we're the first reference on the lock, we need to open the file again.
|
||||
fd, err := openLock(l.file, l.ro)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("error opening %q: %v", l.file, err))
|
||||
panic(err)
|
||||
}
|
||||
l.fd = uintptr(fd)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue