Webdavz.LockIn-memory WebDAV lock manager.
Implements the locking model from RFC 4918 Section 6–7 with exclusive write locks stored in memory.
Locks do not survive server restarts. This is sufficient for macOS Finder and other WebDAV clients that use locks for safe-save workflows.
type lock_info = {token : string;Opaque lock token URI (Section 6.5).
*)path : string;Locked resource path.
*)depth : [ `Zero | `Infinity ];Lock depth. `Infinity covers all descendants.
scope : [ `Exclusive ];Lock scope — only exclusive supported.
*)owner : string option;Optional owner identification from the LOCK request body.
*)timeout_s : int;Lock timeout in seconds.
*)created_at : float;Unix timestamp when the lock was created.
*)}Information about an active lock.
The lock manager. Not thread-safe — use one per connection fiber or protect with a mutex for concurrent access.
val create : unit -> tcreate () creates an empty lock manager.
val lock :
t ->
path:string ->
depth:[ `Zero | `Infinity ] ->
owner:string option ->
timeout_s:int ->
(lock_info, [> `Locked of lock_info list ]) resultlock t ~path ~depth ~owner ~timeout_s attempts to create a lock.
Returns Ok info on success, or Error (`Locked conflicts) if an existing lock conflicts.
val unlock : t -> token:string -> boolunlock t ~token removes the lock with the given token. Returns true if the lock existed.
refresh t ~token ~timeout_s extends a lock's timeout. Returns Some info if the lock exists, None otherwise.
find t ~token returns the lock info for a token, if it exists.
active_locks t ~path returns locks rooted at exactly path.
locks_covering t ~path returns all locks that cover path, including ancestor locks with depth infinity.
check_write t ~path ~lock_token checks if a write to path is permitted. Returns Ok () if the path is unlocked or the correct token is provided. Returns Error lock if blocked.
val lockdiscovery_xml : t -> path:string -> Webdavz__.Webdavz_xml.tree listlockdiscovery_xml t ~path returns the XML children for the DAV:lockdiscovery property, listing all active locks on path.