Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find if the contents in a Google Drive folder have changed

I am currently working on an app that syncs one specific folder in a users Google Drive. I need to find when any of the files/folders in that specific folder have changed. The actual syncing process is easy, but I don't want to do a full sync every few seconds. I am condisering one of these methods:

1) Moniter the changes feed and look for any file changes
This method is easy but it will cause a sync if ANY file in the drive changes.

2) Frequently request all files in the whole drive eg. service.files().list().execute() and look for changes within the specific tree. This is a brute force approach. It will be too slow if the user has 1000's of files in their drive.

3) Start at the specific folder, and move down the folder tree looking for changes. This method will be fast if there are only a few directories in the specific tree, but it will still lead to numerous API requests.

Are there any better ways to find whether a specific folder and its contents have changed? Are there any optimisations I could apply to method 1,2 or 3.

like image 555
Max Ferguson Avatar asked Dec 01 '25 14:12

Max Ferguson


1 Answers

As you have correctly stated, you will need to keep (or work out) the file hierarchy for a changed file to know whether a file has changed within a folder tree.

There is no way of knowing directly from the changes feed whether a deeply nested file within a folder has been changed. Sorry.

like image 192
Ali Afshar Avatar answered Dec 03 '25 05:12

Ali Afshar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!