Skip to content

Fix files not unlocking after lock time expired#4962

Merged
claucambra merged 5 commits into
masterfrom
bugfix/files-not-unlocking
Oct 4, 2022
Merged

Fix files not unlocking after lock time expired#4962
claucambra merged 5 commits into
masterfrom
bugfix/files-not-unlocking

Conversation

@claucambra

@claucambra claucambra commented Sep 20, 2022

Copy link
Copy Markdown
Collaborator

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

codecov Bot commented Sep 20, 2022

Copy link
Copy Markdown

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

@mgallien mgallien left a comment

Copy link
Copy Markdown
Collaborator

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

Comment thread src/libsync/discovery.cpp Outdated
@claucambra

Copy link
Copy Markdown
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 requested a review from mgallien September 21, 2022 13:03
@claucambra claucambra force-pushed the bugfix/files-not-unlocking branch 10 times, most recently from f9c162b to 5758444 Compare September 24, 2022 01:01
Comment thread src/common/syncjournaldb.cpp Outdated
Comment thread src/common/syncjournaldb.cpp Outdated
@claucambra claucambra force-pushed the bugfix/files-not-unlocking branch from 5758444 to a04d0fa Compare September 26, 2022 11:22
Comment thread src/libsync/discovery.cpp Outdated
Comment thread src/libsync/discoveryphase.h
Comment thread src/libsync/syncengine.cpp Outdated
Comment thread src/libsync/syncengine.cpp Outdated
@claucambra claucambra force-pushed the bugfix/files-not-unlocking branch from a04d0fa to d2101a0 Compare September 26, 2022 12:16
@claucambra claucambra force-pushed the bugfix/files-not-unlocking branch from d2101a0 to 2e4b5c3 Compare September 26, 2022 12:51
@szaimen szaimen force-pushed the bugfix/files-not-unlocking branch from 2e4b5c3 to 11a0949 Compare September 28, 2022 08:55
Comment thread src/libsync/discovery.cpp Outdated
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>
@mgallien mgallien force-pushed the bugfix/files-not-unlocking branch from 8af7c0b to 2f57133 Compare October 4, 2022 09:52
@sonarqubecloud

sonarqubecloud Bot commented Oct 4, 2022

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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