WebDAV Locking Mechanisms in LibreOffice
LibreOffice supports standard WebDAV protocol locking mechanisms to prevent data loss and resolve concurrency conflicts when multiple users access remote files. By utilizing native WebDAV lock management, LibreOffice detects whether a remote document is currently in use, acquires server-side locks during edit sessions, and provides fallback alerts when a file cannot be safely modified.
RFC-Compliant WebDAV Exclusive Write Locks
LibreOffice utilizes standard HTTP LOCK requests
conforming to RFC 4918 (and the legacy RFC 2518) to secure exclusive
write access to remote documents:
- Exclusive Write Locks (
writelock type): When a user opens a remote document for editing via the LibreOffice WebDAV Universal Content Provider (UCP), the application issues aLOCKrequest with anexclusivescope. This restricts write permissions on the server exclusively to the user holding the lock token. - Lock Tokens: The server responds with a unique
Lock-Tokenheader. LibreOffice stores and passes this token in theIfheader of subsequentPUT(save) requests to validate that the changes originate from the authorized lock owner. - Shared Locks Handling: While the WebDAV
specification allows for
sharedlocks, LibreOffice defaults to exclusive write locking for edit operations to ensure absolute data consistency.
Lock Discovery and Conflict Detection
Before editing a document, LibreOffice queries the server to determine the lock state of the target file:
PROPFINDLock Discovery: LibreOffice requests thelockdiscoveryproperty from the server.- Read-Only Mode Trigger: If the resource is already locked by another user or client, LibreOffice informs the user that the document is locked for editing. The user is then given options to open the document as read-only, open a local copy, or receive a notification when the file becomes available.
Lock Refresh and Timeout Handling
To maintain an active editing session without losing lock state, LibreOffice manages lock life cycles dynamically:
- Lock Refreshing: WebDAV locks are typically granted
with a specific timeout period. LibreOffice periodically sends
keep-alive
LOCKrequests using the existing lock token to refresh the lock timeout before it expires on the server. - Lock Release (
UNLOCK): When the user closes the document or exits LibreOffice, the application sends a standard HTTPUNLOCKrequest containing theLock-Tokenheader to release the lock immediately for other users.
Fallback and Client-Side Lock Files
When interacting with WebDAV servers that do not fully implement RFC 4918 locking, or when remote connections are managed via operating system mounts (such as GVfs or KIO) rather than LibreOffice’s internal WebDAV client:
- Document Lock Files (
.~lock.*#): LibreOffice may attempt to write hidden lock files directly to the target directory. - Fallback Behavior: If neither native WebDAV locks nor hidden lock files can be established, LibreOffice warns the user that file locking is unavailable, which may lead to concurrent write conflicts if saved remotely.