How does Dropbox determine when to overwrite the local file vs overwrite the cloud file?

10

2

When Dropbox encounters a file on one's computer that is different than the cloud version of that file that it knows about, how does it decide whether it should sync them by overwriting the local file with the cloud file or sync them by overwriting the cloud file with the local file?

To rephrase:

  • If the server copy and the local copy of a file are different,

  • and if the dropbox program is launched and finishes syncing,

  • then these two files will be the same.

These two files will also be identical to one of the old files. My question is which --- the old server copy or the old local copy? How does it decide?

Ein

Posted 2013-12-20T04:16:07.890

Reputation: 337

Mmmm, not sure if your rephrase makes it clearer. But i think Dropbox uses a (version of) file-checksum (and maybe change-date) to see if the file needs to be uploaded. (It has the old ones in its local database). If the checksum is different it goes for an upload. If online there is a version with a newer date and different checksum than the old one in its local database, somebody else must have changed the file and the file will be renamed appending "conflicted copy". (of course this is speculation and i have not found confirmation of this online, yet) – Rik – 2013-12-20T22:28:23.633

Answers

1

I have partial information which begins to answer this question. I'm not sure how useful this is to experienced users, but I know newer users like myself will find this report helpful.

As an aside, working this out makes me even more puzzled how an incredibly basic question doesn't have any official or authoritative answer. The lack of available documentation or discussions tells me that users of Dropbox are fine with taking whatever Dropbox actually does as what they would have expected it to do under those circumstances. (i.e., I wouldn't even say that users have a concrete expectation that they hold dropbox to)

Examples of how Dropbox will behave:

In my examples, computer A and computer B are never both powered on at the same time. Imagine a single user working non-collaboratively at home and work, with each computer being turned off before coming back to the other one.

What happens when one computer's dropbox folder isn't identical to the cloud dropbox folder? For maximum clarity I prefer to imagine how dropbox.exe reacts when one computer has an empty dropbox folder. Will dropbox.exe consider those missing files as "deletions" (which means it will remove them from the cloud dropbox folder) or "out of date" (which means it will create new copies of them inside the local dropbox folder).

  1. Start with situation where the behavior is plainly obvious: Computer A is on and computer B is off. If dropbox.exe is running and changes are made to A, then these are propagated to the cloud folder and not vice versa. So at the moment, if A's folder is emptied, then these missing files/folders are considered "deletions" and the cloud folder is emptied.

  2. Suppose B has an empty dropbox folder, and A creates files and sync these to the cloud dropbox folder. If we switch to computer B, the situation is that dropbox.exe will interpret B's empty dropbox folder as "out of date", and new copies from the cloud folder are created on B.

  3. Now for the less obvious: Suppose we make some changes in B and sync these changes to the cloud dropbox folder. If we switch to computer A and --- without first running dropbox.exe --- we delete things inside A's dropbox folder, what will running dropbox.exe afterwards do? In this situation dropbox.exe will interpret the missing files/folders as new deletions that should be propagated to the cloud dropbox folder.

I find it confusing that in situations 2 and 3 you have dropbox.exe being turned on and encountering the same "fresh" state on a new computer that differs from the cloud folder, but it will act differently.

If you wanted to invent a rule that explains how dropbox.exe operates, you evidently cannot assume it is a function of the three variables: (1) what it sees on the computer right now, (2) what it sees on cloud folder, and (3) which computer was last to sync with the cloud folder. (!!!)

Perhaps the extra variable is that Dropbox remembers what each computer last sync'ed to the cloud folder. In situation 2, we might assume the last time computer B sync'ed, it sync'ed an empty folder. In situation 3, Dropbox remembers that the last time computer A sync'ed, it sync'ed a folder that was different than what it presently finds inside the folder.

Ein

Posted 2013-12-20T04:16:07.890

Reputation: 337

I don't know how you expect Dropbox to keep track of changes when it is not running at all. In Scenario 2, you are adding files to Dropbox, S3 is erasing files from Dropbox. They are two different scenarios and should be behave differently. Not sure where your confusion stems from. Dropbox will make a best effort based on what is in the cloud and on your hard drive at the time you turn on Dropbox. Best way to use Dropbox is to always keep it on. If you have to turn off computers, be careful with deletions. At least DropBox gives you 30 day restores. You think Dropbox is bad, try OneDrive. – Sun – 2014-10-20T18:23:25.453

"I don't know how you expect Dropbox to keep track when it's off" <-- arguably you expect it to, if you expect S3 to act differently from S2. "If you turn off computers, be careful with deletions" <-- As a dropbox user, this is a warning I would like to have seen in the documentation. It's very easy for you to say "it should behave differently" because you aren't stating exactly what it should do. What bothers me is I could not find documentation that actually DOES state what it should do. This is precisely why I was confused: forced to guess what the variables were and getting it wrong! – Ein – 2014-11-12T21:30:40.960

It is actually a very relevant question and I came here from googling the question. My laptop has not been fully synced with Dropbox for at least a year because I ran out of space. So I used selective syncing. Now I have upgraded my HD to a bigger SSD and I want to sync everything again. At lots of files are missing in some folders on my laptop and I am afraid that Dropbox will misinterpret what to do when I sync. Will it add the files from the cloud to the local folders - or will it instead delete the missing files from the cloud? I am not quite sure! – marlar – 2016-10-21T21:03:18.650

1

It's not that dropbox.exe just checks the directory offline and online. Like you state in your last paragraph, dropbox keeps a record of every file stored locally and online so it knows exactly when/what (and when/what not) to sync. Take a look at my dropbox-dir in C:\Users\<name>\AppData\Roaming\Dropbox. You see lots of .dbx-files where dropbox will keep that information (not just dates but also checksums etc...). (Delete those files and dropbox will seriously mess op you dropbox directory online and offline ;)

– Rik – 2014-01-16T15:14:03.380

5

I don't know the technicalities of this, but I do have the situation where I and my assistant operate a common dropbox with two different computers going on and off at different times.

The answer to your question is that when you connect with the Cloud, Dropbox knows (somehow) that the version currently on the Cloud was originally synced from your computer. So if your computer version is different, that is the version that will be synced to the Cloud.

If two computers (say A and B) are using the same dropbox, and each make changes offline, then the first computer powers up (let's say it is computer A) will generate a sync of its update to the cloud. So now there will be same version (containing the A update) on A and Cloud.

When computer B is powered up, Dropbox will realise that computer B's version of the file is not only different from the current cloud version (which is normal) but different from the last time Dropbox synced from it. So if it were to sync B's file to the A version, B's changes would be lost. So what Dropbox does is make a copy of the B version and add "B's conflicted file" to the file name. B's original file is then synced to the A updates. The conflicted file, containing the B updates, is then synced to the cloud and back down to A.

Deletions, and conflicts arising from selective sync, are handled in a similar way

A conflict also arises if one of the computers does not close the file before powering down. Syncing does not occur on an open file, so in this case B's updates will be the ones that are synced, and A's open file will end up as a conflict. This can be a huge pain to harmonize, but this is our fault, not Dropbox's.

Hope this helps.

Margie

Posted 2013-12-20T04:16:07.890

Reputation: 51

-2

From the Dropbox FAQ:

Unlike the Dropbox desktop app, which constantly checks your files for changes, the mobile app usually syncs on demand only. This prevents Dropbox from consuming all of your bandwidth and space.

How does it do this?

That too is mentioned on their site:

Before transferring a file, we compare the new file to the previous version and only send the piece of the file that changed. This is called a "binary diff" and works on any file type. Dropbox compresses files (without any loss of data or quality) before transferring them as well. This way, you also never have to worry about Dropbox re-uploading a file or wasting bandwidth.

Karan Raj Baruah

Posted 2013-12-20T04:16:07.890

Reputation: 894

1I'm asking about a more basic question unrelated to compression/diffs... how does it know when the local file should become the new "most current version" versus whether the local file is "out of date". – Ein – 2013-12-20T10:56:49.330

It's not unrelated to diffs. The Dropbox API knows comparing these diffs when a particular file becomes "outdated" and decides to sync the particular file. Other than this I couldn't find more information. Dropbox itself being closed source hasn't made any more information public. – Karan Raj Baruah – 2013-12-20T11:22:29.163

I have edited the question to rephrase what I'm asking, because there is probably some confusion going on. Also, I can't parse your second sentence. – Ein – 2013-12-20T22:01:16.947