Hello, I would like to ask for some confirmations and clarifications on syncing dropbox files with API v2.
I think I have uploading, downloading and listening for changes mostly figured out.
My problem is proper handling of the scenario where a local file has changed and is scheduled to be uploaded to dropbox through filesUpload, but the remote file has also changed due to a different instance of my app.
I (think I) understand that the correct method to determine that the remote file has changed is by storing the rev value on each download, then check if that rev is still the same before uploading. If local and remote rev differ, the remote file has changed without the local app noticing it until now. In my case, I would ask the user at this point which file he would like to overwrite:
Download the remote file, overwrite local or
upload the local file, overwrite the remote?
(I leave aside here more sophisticated approaches ie creating a “conflicted copy” file or presenting a diff to the user etc.)
Question 1:
Does that workflow above make sense? Are there scenarios I did not consider?
Question 2:
How would I roughly go about that workflow with the sdk endpoints?
I was weighing using files/list_folder/get_latest_cursor + files/list_folder/continue and checking the metadata before files/upload, but my feeling is that files/upload is still the “moment of truth” here, ie still possible that changes occured between checking the metadata from files/list_folder/continue and files/upload.
files/upload offers the write mode “update” with the local rev as parameter, but I read the documentation as stating that if the revs differ, the API will always create a conflicted copy file. I would rather cancel at this point and ask the user what to do, as described above.
Question 3:
Is there a way to configure files/upload with something like “if local rev and remote rev differ, throw an error and cancel filesUpload”?
Thank you very much for any reply!