Bug 117967 - On Linux LibreOffice doesn't protect users from accidental content overwrite when a file was updated outside of LibreOffice and the warning dialog was cancelled out of once
Summary: On Linux LibreOffice doesn't protect users from accidental content overwrite ...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All Linux (All)
: medium normal
Assignee: Matt K
URL:
Whiteboard: target:7.5.0
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-01 23:29 UTC by yury.dubinsky
Modified: 2022-08-09 19:08 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yury.dubinsky 2018-06-01 23:29:30 UTC
There is no problems on Windows because of two facts:
1. Windows supports file shortcuts, but Linux by default supports only symbolic and hard links.
2. Windows locks files, open for update, then other processes cannot modify these files. Linux doesn't provide default file locking.
On Linux, LibreOffice behavior doesn't satisfy best practice.
1. Unlike most text editors, LibreOffice doesn't analyze if a selected file is a symbolic link. LibreOffice opens every symbolic link in a separate window as a different file instance. That allows LibreOffice users to simultaneously  modify the same file in different, unrelated, windows that leads to much confusion.
2. The lack of a default file locking mechanism on Linux is normally resolved by file timestamp validations. Usually the timestamp is being validated in three cases: when a window gets focus, periodically during the editing session, and right before saving on disk. However,  LibreOffice validates  timestamps only in one case, before saving, when users already finished their work. LibreOffice checks the timestamp only one time, after the first attempt to save. The subsequent attempt will overwrite the file on disk without any further confirmation.

1. LibreOffice should validate symbolic links and should not allow opening multiple windows for the same target file, when possible.
2. LibreOffice should validate timestamp before every save command and ask for confirmation every time when the timestamp differs. Not just once.
Comment 1 yury.dubinsky 2018-06-01 23:32:37 UTC Comment hidden (obsolete)
Comment 2 Jean-Baptiste Faure 2018-06-03 11:39:16 UTC
Please, describe a step by step scenario showing that there is a problem under Linux.

My test:
1/ be an existing file foo.odt in the folder A
2/ create a simlink of foo.odt in the folder B
3/ open A/foo.odt
4/ open B/foo.odt
5/ make a change in A/foo.odt
6/ make another change in B/foo.odt
7/ go back to A/foo.odt, then ctrl+S => A/foo.odt is saved
8/ go back to B/foo.odt, then ctrl+S => Warning message that this file as been modified since it has been open in LibreOffice for edition. Saving this version will overwrite previous changes made by others.

For me that is the expected behavior.

Status set to NEEDINFO, please set it back to UNCONFIRMED once requested
informations are provided.

Best regards. JBF
Comment 3 yury.dubinsky 2018-06-04 19:10:29 UTC
Hello, Jean-Baptiste,
This is a design bug. LO behavior is consistent, but wrong from my point of view.
Your scenario is right, just it is incomplete. 
Please, add to more steps:
9/  press cancel
10/ press ctrl+S again. At this point you will not get any confirmation, the content B/foo.odt will be saved. 
The program should confirm with users every time when the timestamp is old.

Also, please, take a look at  step 4. open B/foo.odt. Why is the symbolic link opened as an independent file? The advanced text editors on Linux easily recognize symbolic links and process symbolic links as target files. I mean such editors as gvim/vim, emacs, geany,  visual studio code, kate, and many more. 

In my career I was presenting Linux and LO to few small offices, and I know many real cases when users, with Windows background,  lost content. Let’s take another look at your scenario from human perspective. 
Step 8: an user, familiar with Windows shortcuts, could be not aware that B/foo.odt is a symbolic link. Getting a warning message will entirely surprise this user. Then, normal actions from users are: cancel saving and rapidly move all changes made in B/foo.odt to A/foo.odt.
Both windows have to same title, so, it's very easy to make a mistake and press ctrl+S in the wrong window. Especially when users can assume that in case of a wrong window LO will warn again. However, LO doesn't do it.
Comment 4 Buovjaga 2018-06-21 18:05:12 UTC
Fair enough, let's set to NEW
Comment 5 QA Administrators 2019-06-22 02:50:34 UTC Comment hidden (obsolete)
Comment 6 yury.dubinsky 2019-06-22 23:15:59 UTC
I re-tested per your suggestion.
I installed 6.2.4. Unfortunately, this behaviour was not changed.  There are steps  that I performed.
1. Create a text document. (Or any other LO file) 
2. Create in another directory a soft link to this file.
3. In any file manager click the original file and the link. LO will open the file and the link in two separate windows. 
4. Make a change in one window and save it.
5. Make a change in another window and try to save.  You will receive the pop-up warning with two options: save anyway or cancel. Press Cancel and then save again. The content of the file will be overwritten.

To avoid this problem, we need to check the file timestamp before each save, and not just the first time we try to save.
In addition, most editors check the timestamp every time the window becomes active. Then users will be informed before they start changing the content.
Comment 7 Matt K 2021-03-27 07:41:37 UTC
I repro'd this on Windows 10 64-bit using LibreOffice 7.2.0.0 dev build.  This happens on Windows now due to the following regression I found: https://bugs.documentfoundation.org/show_bug.cgi?id=141279
Comment 8 Commit Notification 2022-07-30 04:27:45 UTC
Matt K committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/07250a832787acdd432dccd458536de2987a58b2

tdf#117967 Fixes Save confirmation dialog for user cancel

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 9 Buovjaga 2022-08-09 11:35:13 UTC
Thanks for the commit. Any more work needed or can this be closed as fixed?
Comment 10 Matt K 2022-08-09 19:08:36 UTC
(In reply to Buovjaga from comment #9)
> Thanks for the commit. Any more work needed or can this be closed as fixed?

It can be closed ... updating status.