File Locking#
Mountain Duck supports locking files to prevent conflicting edits from others while a document is open in an editor.
Overview#
Mountain Duck uses two mechanisms to detect that a file is being edited by someone else, depending on the protocol and the connect mode.
Online |
Smart Synchronization |
Integrated |
|
|---|---|---|---|
Native server-side locking |
✔ Files are locked when opened in an editor |
✔ Files are locked when opened in an editor |
✔ Files locked on the server can’t be edited. |
Pseudo locking using lock owner files |
✔ |
✔ |
✔ Files with a lock owner file not created locally can’t be edited. |
Locking is disabled by default.
Native Server-Side Locking#
File locking is natively supported for the following protocols:
Nextcloud with the Files Lock app (
files_lock) installed and enabled on the serverownCloud Server with built-in file locking
Note
Some WebDAV implementations may not support locking documents. Dropbox locking requires a Pro or Business account.
Online and Smart Synchronization#
Mountain Duck locks files on the server when opened in an editor. This prevents other users from modifying the document until the file is closed by the user.
When the file is already locked by another user, opening it for writing fails and the error is returned to the application.
The error is returned as an access error. The application can’t open the document for editing and offers to open it read-only or to save a copy, as shown in Error Message when Opening Locked Documents. The message is generated by the application and doesn’t name the user holding the lock.
The error is returned as a sharing violation, the same error returned by Windows for a document opened by another user. Applications such as Microsoft Word and Excel respond with their File in Use message and offer to open the document read-only or to be notified when it becomes available, as shown in Error Message when Opening Locked Documents.
Integrated#
A lock is requested on the server when a document is opened for writing in an editor and released when closed. Files that are locked on the server by another user are set read-only so they can’t be edited, renamed, moved or deleted until the lock is released. A lock you hold yourself doesn’t make the file read-only.
The write, rename, move and delete capabilities are removed from the file in the File Provider extension. The system then sets the Locked flag (uchg) on the file, which is shown in Finder.app.
Write and delete permissions are removed from the file in the Cloud Files sync root, setting the file read-only in Windows Explorer.
Pseudo Locking for Protocols with no Native Lock Support using Lock Owner Files#
For connections to servers without native lock support, we support detecting files opened by others by looking for lock owner files uploaded to the server by the editing application. This applies to all connect modes, including Integrated.
When opening a file for editing, the server is searched for a lock owner file matching the file. A file is locked and prevented from being edited when a lock owner file is found that was not created by the application on your own computer, that is, the file is opened by another user or on another computer. Lock owner files created locally and uploaded by the editing application are recognized and don’t lock the document for you. When a lock owner file of a third party is found, opening the file for editing is denied and a notification is displayed.
Note
Support is currently limited to files edited in Microsoft Word, Microsoft Excel, Microsoft PowerPoint, Microsoft Visio, Microsoft Access, LibreOffice, OpenOffice and Euro-Office on macOS and Windows.
Application |
Lock owner file |
Documents |
|---|---|---|
Microsoft Office |
|
|
Microsoft Access |
|
|
LibreOffice, OpenOffice, Euro-Office |
|
|
Lock owner files are hidden in the mounted volume.
Attention
Excel 97-2003 files are not included because Excel doesn’t create lock files for those file types: *.xls, *.xlt, *.xla.
References#
When a previously saved file is opened for editing, for printing, or for review, Word creates a temporary file that has a .doc file name extension. This filename extension begins with a tilde (~) that is followed by a dollar sign ($) that is followed by the remainder of the original file name. This temporary file holds the login name of the person who opens the file. This temporary file is called the “owner file”.
Error Message when Opening Locked Documents#
Attempting to open a locked document, an error message is displayed notifying the document can only be opened in read-only mode. Samples of error messages from different applications.
Microsoft Word
Read Only. To save a copy of this document, click Duplicate
Libre Office
Document ... is locked for editing by... . Open document read-only or open a copy of the document for editing.
Microsoft Word
This file is already open by another user. Would you like to make a copy of this file for your use?
Choose Receive notification when the original copy is available to open the document in read-only mode and get an alert when the other user has closed the document.
Microsoft Excel
File in Use: File is locked for editing by ... . Open 'Read-Only' or click 'Notify' to open read-only and receive notification when the document is no longer in use.
Choose Notify to open the document in read-only mode and get an alert when the other user has closed the document.
Resolution#
If you get a warning that the document is Read-Only, ask other users to close the document. If the Read-Only warning prevails, these are the steps to follow.
If you are connecting to a server with native lock support (such as WebDAV), ask the server administrator to clean up locks on the server.
For all other servers, delete the lock owner file named
~$...(Microsoft Office),.~lock...#(LibreOffice, OpenOffice, Euro-Office) or*.laccdb(Microsoft Access).
Preferences#
Locking is disabled by default. Refer to Preferences to enable it in Sync → Locking → Lock Files.
Limitations#
Due to Dropbox file restrictions lock files are forbidden files and can’t be uploaded. Therefore, pseudo file locking is not available using Dropbox.
Nextcloud via WebDAV supports native locking only with the Files Lock app installed on the server. Native locking is built in for ownCloud Infinite Scale & OpenCloud. Otherwise make sure to select Nextcloud & ownCloud in the bookmark configuration to make use of pseudo locking.
Excel 97-2003 files (
.xls,.xlt,.xla) are not supported by pseudo locking.