desktop icon indicating copy to clipboard operation
desktop copied to clipboard

Fix files not unlocking after lock time expired

Open claucambra opened this issue 3 years ago • 4 comments
trafficstars

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 [email protected]

claucambra avatar Sep 20 '22 21:09 claucambra

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

codecov[bot] avatar Sep 20 '22 21:09 codecov[bot]

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 avatar Sep 21 '22 11:09 claucambra

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.

nextcloud-desktop-bot avatar Oct 04 '22 10:10 nextcloud-desktop-bot

/backport to stable-3.6

claucambra avatar Oct 18 '22 09:10 claucambra