0
votes

Hello I am learning how dropbox, Google Drive app always keep sync everything in a very nicely way. I want to learn from those how actually they are doing.

I have this approach to do same like create a database in the app. Once a user add a file into that folder then add that file info in the database and uploaded status as well.

At the same when any file is added/updated/deleted then update status of uploaded and start to upload the file.

I'm not sure if I am wrong in this approach, please guide you guys may know more about this sure.

And I want to know how dropbox app keep SD card folder of my android phone always sync even when I delete the any file of that folder from anywhere like browser.

Whenever user delete any file from browser or anywhere then at the same time, dropbox remove that file from that folder in my SD card. How they are doing this ? Are they using using push notification system or running service in a gap of 1 seconds to know whether any files is updated/added/deleted.

Thanks in advance.

2

2 Answers

0
votes

i'm sure exporting is an improvement but why not the ability to sync an sd card folder to dropbox? I think that might be more useful and more in line with the purpose of dropbox. Coming from Apple I am surprised at all the things I can do with Android and files I can download. I would be nice to have a dropbox folder on my device that is synced and backed up to the cloud.

0
votes

Detecting changes

The hardest part is the make a difference between 2 types of 'new files' Just a new file that has been posted, or a files that was recently deleted, this is how you decide whether to delete the latter or the copy it to the missing destination. The same happened when you move a file from one folder to the other. Most of these sync system use hidden files to store file movements, history (renaming, permission, changes, .. ) and deletion. These can be detected with kernel subsystems on linux with inotify for example

This way, as soon as a sync is requested, the app syncs both ways with a central server, which records last sync request. All other connected clients are checking for the last sync time, if it is newer, they initiate a sync to that time.

2 existing approaches :

p2p systems like bittorent sync, this system is able to sync between every peer, there is no central space

generic 2 way syncs like Unison, which is made on top of rsync and stores the needed info to know how to handle moved, renamed and deleted files.

Polling interval

About the time interval, it is a good idea to have it dynamic. based on the last sync. If a sync is recent, check it every 10 seconds, if a sync was made a couple of days ago, make it 30 seconds, and so on. people don't mind waiting between 0 and 10 seconds to see the first change, but they would mind if they had to wait 10 seconds again and again. so if changes are very recent like < 1 min, check it every 1 or 2 seconds.

1 or 2 seconds starting from the last reply, not the last request, or you would end up filling a queue if for some reason the request take longer than 1 second to come back.