Closed kc9jud closed 6 years ago
DriveSync only syncs files that are owned by the user, yes. The reason for this is that I figured that most users only want files on their local system that actually fully "belong" to them. Also, shared files can get a bit messy on Drive, especially files that were shared a long time ago (for example, it turned out that on my Drive there were some files that were shared with me years ago, that only show up in the API call, but nowhere on the web client and that I couldn't remove from my Drive).
However, changing this should be trivial - looks like you already found the relevant part of the code. Simply remove the "and belongs_to_me?(file)" in both lines and it should work fine. I will add an option to enable this behavior in the next release.
When I tried removing those, DriveSync started downloading everything which had been shared with me, not just things I had added to My Drive... does the Drive API expose whether something is living under My Drive? If so, then and belongs_to_me?(file)
would become something like and (belongs_to_me?(file) or in_my_drive?(file)
...
I just went through every single property that the Google Drive API exposes for shared files and the only difference between files that have been added to your Drive and those that have not, is that files in your Drive have a "Parents" property that shows the actual location of the file. Probably not an ideal solution, but adding return true if file.parents != nil and file.parents != []
as the first line in belongs_to_me should accomplish what you want.
I will push this change along with a corresponding entry in the config file and probably some error handling in case you try to delete a file that doesn't belong to you to a development branch soon.
I'm just getting started with DriveSync -- I noticed that it doesn't sync things which have been shared with me that I've added to My Drive: https://github.com/MStadlmeier/drivesync/blob/1f8275979c66a6a9e70bf55a5ea9c6518f9647f7/src/drive_manager.rb#L70-L71 Is there a way to sync things I don't own but are in My Drive?