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

Function acquireLock

lib/interfaces/webdav-locks.ts:61–80  ·  view source on GitHub ↗
(userId: string, path: string, depth: 'infinity' | '0')

Source from the content-addressed store, hash-verified

59}
60
61export function acquireLock(userId: string, path: string, depth: 'infinity' | '0'): { token: string } | null {
62 if (findBlockingLock(userId, path, [])) {
63 return null;
64 }
65
66 if (depth === 'infinity' && hasDescendantLock(userId, path)) {
67 return null;
68 }
69
70 const token = `opaquelocktoken:${crypto.randomUUID()}`;
71
72 locksByKey.set(buildKey(userId, path), {
73 token,
74 path,
75 depth,
76 expiresAt: new Date(Date.now() + LOCK_TIMEOUT_IN_MILLISECONDS),
77 });
78
79 return { token };
80}
81
82// A lock can be refreshed via a member URI too (e.g. a file inside a Depth: infinity-locked collection).
83export function refreshLock(

Callers 1

handlerFunction · 0.90

Calls 4

findBlockingLockFunction · 0.85
hasDescendantLockFunction · 0.85
buildKeyFunction · 0.85
setMethod · 0.80

Tested by

no test coverage detected