MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / findBlockingLock

Function findBlockingLock

lib/interfaces/webdav-locks.ts:40–59  ·  view source on GitHub ↗
(userId: string, path: string, presentedTokens: string[])

Source from the content-addressed store, hash-verified

38
39// A lock on any ancestor collection with Depth: infinity covers this path too.
40export function findBlockingLock(userId: string, path: string, presentedTokens: string[]): WebDavLock | null {
41 const exactLock = locksByKey.get(buildKey(userId, path));
42
43 if (exactLock && !isExpired(exactLock) && !presentedTokens.includes(exactLock.token)) {
44 return exactLock;
45 }
46
47 for (const ancestorPath of getAncestorPaths(path)) {
48 const ancestorLock = locksByKey.get(buildKey(userId, ancestorPath));
49
50 if (
51 ancestorLock && ancestorLock.depth === 'infinity' && !isExpired(ancestorLock) &&
52 !presentedTokens.includes(ancestorLock.token)
53 ) {
54 return ancestorLock;
55 }
56 }
57
58 return null;
59}
60
61export function acquireLock(userId: string, path: string, depth: 'infinity' | '0'): { token: string } | null {
62 if (findBlockingLock(userId, path, [])) {

Callers 2

handlerFunction · 0.90
acquireLockFunction · 0.85

Calls 4

buildKeyFunction · 0.85
isExpiredFunction · 0.85
getAncestorPathsFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected