palant/pfp

Add Google Drive as another storage provider

palant opened this issue · 2 comments

In #24 we implemented Dropbox as the only storage provider. We should add Google Drive and let the user choose which one they want to use.

Unless I am totally mistaken, only v2 API has a way to deal with concurrent modifications by means of the ETag header. The newer v3 API dropped that feature without providing a replacement. That means that we have to use the older v2 API for sync. According to this announcement, both API versions will be supported in parallel - this doesn't seem to have changed yet. I just hope that Google won't decide to deprecate v2 API tomorrow...

Working with the Google Drive API is significantly more complicated than with the Dropbox API. Part of the issue is that files aren't really identified by name but rather by a file ID that cannot be set by the application. So while v2 API makes it possible to avoid conflicts when a file is replaced, doing the same for file creation is impossible - the files will have the same name but different IDs. While it should be possible to restore a consistent state in this case, this is fairly complicated and error-prone. I decided that this complexity isn't worth doing - the probability of two devices doing the initial sync at the same time is small to non-existent. Instead, an error message will show up if multiple conflicting files are seen in the account, advising the user to delete app data.