mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 00:38:49 +01:00
This commit is contained in:
parent
32ab7b52af
commit
99261db73a
2 changed files with 26 additions and 9 deletions
|
|
@ -495,6 +495,25 @@ func tryLockWorkspace() {
|
|||
os.Exit(ExitCodeWorkspaceLocked)
|
||||
}
|
||||
|
||||
func IsWorkspaceLocked(workspacePath string) bool {
|
||||
if !gulu.File.IsDir(workspacePath) {
|
||||
return false
|
||||
}
|
||||
|
||||
lockFilePath := filepath.Join(workspacePath, ".lock")
|
||||
if !gulu.File.IsExist(lockFilePath) {
|
||||
return false
|
||||
}
|
||||
|
||||
f := flock.New(lockFilePath)
|
||||
defer f.Unlock()
|
||||
ok, _ := f.TryLock()
|
||||
if ok {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func UnlockWorkspace() {
|
||||
if nil == WorkspaceLock {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue