-
Notifications
You must be signed in to change notification settings - Fork 811
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
Lock file when editing locally #5226
Conversation
Does this then also cover on all platforms:
Right now it seems that it is the other way around: |
the modifications from @claucambra would be to lock always a file before calling the external editor software (they are unrelated to VFS, the comment is a bit misleading there) what would be missing from the specification (if I understand correctly) would be:
do we want to do more ? |
I will add a notification for this, seems like we should tell the user this About the 30 minute timeout, do we want to defy the server default on this? |
@tobiasKaminsky @mgallien added a notification, screenshot in PR description |
396f646
to
5b51f8c
Compare
@claucambra Besides my other 2 comments, there is one more thing that came to my mind. What happens if the file we are opening is already locked by someone else? The |
We already sync the folder when we start the edit locally process, so we know whether it is locked or not at the point of beginning the edit We don't try to lock the file if we know at the point of edit that it is locked, and we only run the folder sync again after starting edit if we know we are locking it |
8f55eed
to
5ef63db
Compare
4045b14
to
8232e1e
Compare
Ok, I also forgot that we check if the file is locked or not on the server, and, by the way, we have a server bug when we can't see an "Edit locally" menu if we locked a file. But this is for the server team :) |
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.
- I am still facing an assert when I have a file already synced and up-to-date in a folder that points to a remote subfolder (e.g. /docs). In my case, I can see that
&SyncEngine::itemCompleted
has been triggered, but, the SyncJournal record has not been updated yet, and this is the way you are checking the locked state in the assert. So, I recommend taking the parameter of&SyncEngine::itemCompleted
and asserting its lockstate as it has already proper data. - While I've been working on my recent PR for file local editing, I have noticed also that
&SyncEngine::itemCompleted
will not get called if the file was up-to-date, so I had to also subscribe to&SyncEngine::itemDiscovered
to catch that behavior by checking ifitem->_instruction == CSYNC_INSTRUCTION_NONE
, which means the&SyncEngine::itemCompleted
will never get emitted. Kindly make sure this situation is covered. The easiest is to create a second folder connection and just sync one small folder with some files so you can test it then without having to sync the entire cloud.
Thanks @allexzander I was unaware of this potential case, have addressed it now |
ea115d6
to
4c9002f
Compare
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.
@claucambra I am not convinced this is the right place to call something that starts network requests. Probably, it is a limitation by Qt (IIRC network calls must be made from the main thread). I have been testing this PR and I can see that files are not always locked remotely.
See which signals are triggered when you put breakpoints in the void Account::setLockFileState(const QString &serverRelativePath, SyncJournalDb * const journal, const SyncFileItem::LockStatus lockStatus)
.
When locking/unlocking files via context menu - those signals will get triggered. When locking the file via Edit Locally
, Lock job never finishes. It just starts and the finished
signal is never called.
If you move this lockFile()
call outside of the QtConcurrent::run
, you will have noticed the signals are now getting emitted properly.
I propose you do the locking as a last step in the sequence, and then call
QtConcurrent::run([localFilePathUrl, this]() { QDesktopServices::openUrl(localFilePathUrl); });
after the LockJob has finished (successfully) or if it never ran because the file was already locked.
So we go:
1. Make the local file up-to-date on disk (already implemented)
2. Lock it if needed and wait till LockJob succeeds
3. Call the openUrl
function after the LockJob has succeeded or if the file was already locked.
Makes sense?
Signed-off-by: Claudio Cambra <[email protected]>
Signed-off-by: Claudio Cambra <[email protected]>
…ting lock Signed-off-by: Claudio Cambra <[email protected]>
… not root to work correctly Signed-off-by: Claudio Cambra <[email protected]>
…ate file record when checking lock state in fileLockSuccess, separate case with lock already pre-existing Signed-off-by: Claudio Cambra <[email protected]>
…ocked remotely Signed-off-by: Claudio Cambra <[email protected]>
4c9002f
to
4e508d0
Compare
Signed-off-by: Claudio Cambra <[email protected]>
…Minutes Signed-off-by: Claudio Cambra <[email protected]>
Signed-off-by: Claudio Cambra <[email protected]>
AppImage file: nextcloud-PR-5226-58f91072a5eaa1ddfef321b8ec8f2b34ef2cb5ce-x86_64.AppImage |
Kindly clean up the history before merge |
SonarCloud Quality Gate failed. |
/backport to stable-3.6 |
Closes #5101
Signed-off-by: Claudio Cambra [email protected]