I'm trying to implement a file synchronization between a local folder and a distant Google Drive. The classic problem is when some modifications are made on both sides simultaneously. So when I update a file locally, I have to make sure file has not been modified on Google Drive before performing the upload so that I can manage conflicts. Regarding Google Drive SDK, I have multiple options to detect that:
- Download the file metadata just before uploading to check that etag has not changed since last upload.
- Consume a changes feed periodically and check file etags in a de-correlated way.
Google seems to privilege the second option. But with both of them, there is no way to be sure that file has not been modified at the time of upload. Basically, I need an atomic upload operation which:
- Checks that etag is the same as last update. If not throws an error.
- If ok, updates the uploaded file
Is there any way to do this?
Thanks