| 289 | } |
| 290 | |
| 291 | func (m *memLS) canCreate(name string, zeroDepth bool) bool { |
| 292 | return walkToRoot(name, func(name0 string, first bool) bool { |
| 293 | n := m.byName[name0] |
| 294 | if n == nil { |
| 295 | return true |
| 296 | } |
| 297 | if first { |
| 298 | if n.token != "" { |
| 299 | // The target node is already locked. |
| 300 | return false |
| 301 | } |
| 302 | if !zeroDepth { |
| 303 | // The requested lock depth is infinite, and the fact that n exists |
| 304 | // (n != nil) means that a descendent of the target node is locked. |
| 305 | return false |
| 306 | } |
| 307 | } else if n.token != "" && !n.details.ZeroDepth { |
| 308 | // An ancestor of the target node is locked with infinite depth. |
| 309 | return false |
| 310 | } |
| 311 | return true |
| 312 | }) |
| 313 | } |
| 314 | |
| 315 | func (m *memLS) create(name string) (ret *memLSNode) { |
| 316 | walkToRoot(name, func(name0 string, first bool) bool { |