1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-09 23:42:20 +08:00

clean up and fix init permissions handling

This commit is contained in:
Jeromy
2015-05-20 08:55:16 -07:00
parent 01e1e71221
commit 8ea502f1b3
5 changed files with 82 additions and 19 deletions

View File

@ -2,6 +2,7 @@ package lock
import (
"io"
"os"
"path"
lock "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/camlistore/lock"
@ -17,14 +18,17 @@ func Lock(confdir string) (io.Closer, error) {
return c, err
}
func Locked(confdir string) bool {
func Locked(confdir string) (bool, error) {
if !util.FileExists(path.Join(confdir, LockFile)) {
return false
return false, nil
}
if lk, err := Lock(confdir); err != nil {
return true
if os.IsPermission(err) {
return false, err
}
return true, nil
} else {
lk.Close()
return false
return false, nil
}
}