Skip to content
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

Fix files not unlocking after lock time expired #4962

Merged
merged 5 commits into from Oct 4, 2022

Conversation

claucambra
Copy link
Collaborator

@claucambra claucambra commented Sep 20, 2022

We have a bug where files are not unlocked after the lock timer expires. This is because there is no indication to the sync engine that a local lock state different to the server lock state needs to be acted on; on top of that, the call to update a file's metadata does not update the lock state of a file.

This PR fixes both of these issues by setting the instruction of an item with a local lock state different to the server to CSYNC_INSTRUCTION_UPDATE_METADATA, and also ensures that lock state is updated in the database in the call to updateLocalMetadata. It also starts a remote check when the file lock expires.

EDIT: This PR now also schedules sync runs for files that need one to check lock status after the lock times out. Sync runs are minimised by grouping files into buckets of files that need sync runs within 60 seconds of each other, with sync occurring at the latest time possible (i.e. the file in that bucket with the latest sync run request time). Scheduled sync runs are also unscheduled if the file becomes unlocked by the user.

Closes #4956

Signed-off-by: Claudio Cambra claudio.cambra@gmail.com

@claucambra claucambra self-assigned this Sep 20, 2022
@claucambra claucambra force-pushed the bugfix/files-not-unlocking branch 3 times, most recently from 87966f7 to c24e271 Compare September 20, 2022 21:50
@codecov
Copy link

codecov bot commented Sep 20, 2022

Codecov Report

Merging #4962 (2f57133) into master (e5d5471) will increase coverage by 0.11%.
The diff coverage is 54.08%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4962      +/-   ##
==========================================
+ Coverage   57.12%   57.23%   +0.11%     
==========================================
  Files         138      138              
  Lines       17228    17359     +131     
==========================================
+ Hits         9842     9936      +94     
- Misses       7386     7423      +37     
Impacted Files Coverage Δ
src/common/checksums.h 0.00% <ø> (ø)
src/common/ownsql.h 100.00% <ø> (ø)
src/common/remotepermissions.h 9.09% <0.00%> (ø)
src/common/result.h 15.78% <0.00%> (ø)
src/common/syncfilestatus.h 50.00% <ø> (ø)
src/common/syncjournaldb.h 66.66% <0.00%> (ø)
src/common/utility.cpp 68.12% <ø> (ø)
src/common/utility.h 0.00% <ø> (ø)
src/csync/csync.h 75.00% <ø> (ø)
src/csync/csync_exclude.h 0.00% <ø> (ø)
... and 39 more

@claucambra claucambra force-pushed the bugfix/files-not-unlocking branch 3 times, most recently from cd6f3ab to 792dab6 Compare September 21, 2022 00:26
Copy link
Collaborator

@mgallien mgallien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice to have a specific automated test to cover explicitly the scenario of the linked github issue

src/libsync/discovery.cpp Outdated Show resolved Hide resolved
@claucambra
Copy link
Collaborator Author

would be nice to have a specific automated test to cover explicitly the scenario of the linked github issue

Added local file lock state checking to the existing test for file locking

@claucambra claucambra force-pushed the bugfix/files-not-unlocking branch 4 times, most recently from cbac230 to 95f0dce Compare September 21, 2022 12:12
@claucambra claucambra force-pushed the bugfix/files-not-unlocking branch 10 times, most recently from f9c162b to 5758444 Compare September 24, 2022 01:01
src/libsync/discovery.cpp Outdated Show resolved Hide resolved
src/libsync/discoveryphase.h Show resolved Hide resolved
src/libsync/syncengine.cpp Outdated Show resolved Hide resolved
src/libsync/syncengine.cpp Outdated Show resolved Hide resolved
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
…runs

Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
…ound the sync run is no longer needed

Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
@sonarcloud
Copy link

sonarcloud bot commented Oct 4, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

74.8% 74.8% Coverage
0.0% 0.0% Duplication

@nextcloud-desktop-bot
Copy link

AppImage file: nextcloud-PR-4962-2f571337f18e559152521accb65d858905907b75-x86_64.AppImage

To test this change/fix you can simply download above AppImage file and test it.

Please make sure to quit your existing Nextcloud app and backup your data.

@claucambra claucambra merged commit b9f6d91 into master Oct 4, 2022
@claucambra claucambra deleted the bugfix/files-not-unlocking branch October 4, 2022 10:58
@mgallien mgallien added this to the 3.7.0 milestone Oct 4, 2022
@claucambra
Copy link
Collaborator Author

/backport to stable-3.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Desktop Client doesn't unlock file
4 participants