MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / runtimeSetLockOwner

Function runtimeSetLockOwner

pkg/go/cmd/codebase-memory-mcp/main.go:1603–1640  ·  view source on GitHub ↗
(lockPath string)

Source from the content-addressed store, hash-verified

1601}
1602
1603func runtimeSetLockOwner(lockPath string) (runtimeSetLockOwnerRecord, bool) {
1604 var empty runtimeSetLockOwnerRecord
1605 status, err := os.Lstat(lockPath)
1606 if err != nil || status.Mode()&os.ModeSymlink != 0 ||
1607 (!status.Mode().IsRegular() && !status.IsDir()) {
1608 return empty, false
1609 }
1610 ownerPath := lockPath
1611 if status.IsDir() {
1612 ownerPath = filepath.Join(lockPath, runtimeSetLockOwnerFile)
1613 }
1614 ownerStatus, err := os.Lstat(ownerPath)
1615 if err != nil || !ownerStatus.Mode().IsRegular() {
1616 return empty, false
1617 }
1618 ownerFile, err := platformOpenRuntimeSetLockOwner(ownerPath)
1619 if err != nil {
1620 return empty, false
1621 }
1622 if runtimeSetLockOwnerReadObserver != nil {
1623 runtimeSetLockOwnerReadObserver()
1624 }
1625 data, readErr := io.ReadAll(ownerFile)
1626 closeErr := ownerFile.Close()
1627 if readErr != nil || closeErr != nil {
1628 return empty, false
1629 }
1630 var record runtimeSetLockOwnerRecord
1631 if err := json.Unmarshal(data, &record); err != nil {
1632 return empty, false
1633 }
1634 decoded, decodeErr := hex.DecodeString(record.Token)
1635 if record.PID <= 0 || record.Token != strings.ToLower(record.Token) ||
1636 decodeErr != nil || len(decoded) != runtimeSetLockTokenSize {
1637 return empty, false
1638 }
1639 return record, true
1640}
1641
1642func runtimeSetSameLockObject(left, right os.FileInfo) bool {
1643 return left != nil && right != nil && os.SameFile(left, right) &&

Callers 4

runtimeSetTryReclaimLockFunction · 0.85
acquireRuntimeSetLockFunction · 0.85
releaseRuntimeSetLockFunction · 0.85

Calls 2

CloseMethod · 0.80

Tested by

no test coverage detected