-
Notifications
You must be signed in to change notification settings - Fork 109
fix(sync): only save on close if changes were made #4503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Max <[email protected]>
1 failed tests on run #11019 ↗︎Details:
|
|||||||||||||||||||||
| Test | Artifacts | |
|---|---|---|
| Sync > recovers from a lost connection |
Output
Screenshots
|
|
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice catch 🎣
|
/compile |
Signed-off-by: nextcloud-command <[email protected]>
| unsubscribe('text:image-node:delete', this.onDeleteImageNode) | ||
| if (this.dirty) { | ||
| const timeout = new Promise((resolve) => setTimeout(resolve, 2000)) | ||
| await Promise.any([timeout, this.$syncService.save()]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something but wouldn't this be called after the text session has been closed already then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The text session is closed afterwards where we destroy all the providers - one of which is the SyncServiceProvider which will close the session on destruction.
Only if the save takes longer than the timeout the provider will be destroyed never the less.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, makes sense. I just got confused by the close/_close methods of the sync service and how they would be triggered as I assumed that the viewer close calls them, but that doesn't seem to be the case. 👍
|
Failure is unrelated |
|
/backport 0fe2f30 to stable27 |
|
/backport 0fe2f30 to stable26 |
📝 Summary
When opening the same file over and over again in the page-links test in collectives the file turns empty after some time.
This is due to the file getting saved before it's even been loaded. So it will be saved empty.
This fix is more broad then that. It will ensure files are only saved during close if any undoable changes have been made to them - the same logic we also apply on autosave.
(This is more a sideeffect of this and fix(sync): Save even if versions match #4286). If there are no changes close is fast now. If there are changes we don't wait for a sync loop anymore (since a while) and due to fix(sync): Save even if versions match #4286 it will still save.
🏁 Checklist
npm run lint/npm run stylelint/composer run cs:check)