cozy-labs / cozy-desktop

File Synchronisation for Cozy on Desktop and Laptop
https://cozy-labs.github.io/cozy-desktop/
GNU Affero General Public License v3.0
99 stars 45 forks source link

fix: Avoid PouchDB conflicts when merging moves #2268

Closed taratatach closed 1 year ago

taratatach commented 1 year ago

When a document being synchronized with the remote Cozy is moved on the local filesystem, we fail to merge the move in PouchDB because we fetch the source record before it is updated by Sync (i.e. to add the remote info) and get a conflict error since we don't have the new revision.

Fetching the source record (again) right before merging the move, when Merge has the PouchDB lock, solves this problem.

This should not create new issues as Merge should be able to handle potential situations where changes to the source record are more substantial than adding remote metadata.

Please make sure the following boxes are checked:

taratatach commented 1 year ago

I could not figure out a way to build an automated test since it is very time sensitive and our test helpers do not give enough control here. I tested it manually though.