nextcloud / files_lock

GNU Affero General Public License v3.0
24 stars 8 forks source link

MD files not locked? #76

Closed rogermartensson closed 2 years ago

rogermartensson commented 2 years ago

Version: 20.1.0 NC: 22.2.8

Scenario: Two users where User 1 has shared a folder with User 2. User 2 creates a text document (.md) in the shared folder and Locks it. User 1 is able to edit the document.

It is the same result if User 1 creates a file in the folder. User 2 is able to edit the document.

We have installed Only Office and if we use Only Office documents it works.

superz3n commented 2 years ago

I also encounter this issue where any file that's shared with someone, even though locked by the owner, the other person is able to acces and edit the file.

Nextcloud Hub II (23.0.5)

danxuliu commented 2 years ago

Text files seem to not be locked, although they actually are:

If you check the downloaded file its contents will be Original, as saving the file was prevented by the lock. However, if you open again the file with the text editor the contents will be Modified. Moreover, if you share the file to another user and open the file as that other user the editor contents will also be Modified, but if the file is downloaded again the contents will be Original.

Why?, you may ask. To be able to provide collaborative edition the editor keeps a list of changes done to the file since the last saving and applies them when the editor is opened. If I am not mistaken this is why the editor shows Modified, while the actual file contents are still Original.

To make things more interesting, if the owner of the share opens the text file again with the editor then the changes will be applied by the text editor of that user, and as that user is the one who has the lock the file will be successfully saved with the changes done by the other users.

In Nextcloud 24 locking was implemented for the text editor, so if another user opens a locked file a warning is shown and the file is opened in read only mode, thus preventing the scenario described above.

That required changes in both the Text and Temporary files lock apps, and unfortunately it is very unlikely that it will be backported to any version before Nextcloud 24. If you need the fix you will need to backport it yourself (not recommended) or upgrade to Nextcloud 24 (recommended).