Problem with synchronisation with spreadsheet
Please use the 👍 reaction to show that you are affected by the same issue. Please don't comment if you have no relevant information to add!
Describe the bug
Continuation of the story https://github.com/nextcloud/forms/issues/2165. I noticed that this does not always work.
To Reproduce
Steps:
- Open the file via richdocuments.
- Fill out the form.
- After completing the form, make changes to the open file and save.
Result: The last submission will be overwritten by the version from richdocuments.
Expected behavior
It will not allow saving in richdocuments. It will ask to download the updated version first.
Additional context
The solution I found: In richdocuments, listen to PostWriteListener and if it is CLI, invalidate (delete) all tokens for this file.
Result: All users of the file will receive a message that they need to reload the page. They reload and get the latest version.
Disadvantage: If users had unsaved changes, they will be lost. In my opinion, this is less critical because the user will see that their connection has been lost and will understand that they need to check if all changes are there (plus richdocuments has auto-save, so the impact is minimal). Because now, when richdocuments overwrites Submission, there is no way to track it, and it causes a lot of problems.
@susnux @Chartman123 The bug is quite complex and my solution is not perfect. Therefore, I would appreciate your expert opinion.
@AIlkiv what about other office suites like OnlyOffice? the solution shouldn't be specific to Nextcloud Office/Collabora. Is there a way to try to obtain a file lock first and if it's already locked, we postpone the write job?
@AIlkiv what about other office suites like OnlyOffice? the solution shouldn't be specific to Nextcloud Office/Collabora. Is there a way to try to obtain a file lock first and if it's already locked, we postpone the write job?
Richdocuments only locks the file during the saving process. As far as I know, locking the file for the entire time it is open is not an option, because the lock should not be applied to users (since collaboration should be possible), but to apps (for example, making the file locked for Collabora Online).
But this solution also has its drawbacks: the user can simply open the file in a separate tab and keep it open all day, so the submission will not appear.
The ideal solution would be if Collabora Online had an API that could be used to update the file if it is open (like when a user logs in to edit it). Then, at the Forms level, the export logic could be broken down into different providers. But I doubt that this will ever be possible.
I understand what you mean, so my suggestion is to add this logic to richdocuments, not forms. Because it seems that it will also be useful for Nextcloud Flow or other modules that can modify the file. I don't work with OnlyOffice, but I can report it there so that they write their own listener.
But the linked document should at best never be edited manually as the sync job will overwrite the data at least in the first sheet. So users should make a copy of it and edit the copy. Everything else will nearly always lead to data loss...
@juliusknorr Perhaps you have ideas on how to best solve this problem on richdocuments?
Maybe an interesting one for @pedropintosilva from Collabora.
There are APIs to transform documents however they currently would also have the same issue with editing conflicts or possible overriding of the files.