I'm developing an application that might use Dropbox as it's storage.
My question is, you can link folders between computers, so that more than 1 person could upload/download to/from the same folder.
Do I have to worry about threading? What happens if while a person is downloading a file, the other person is updating the same file. Does dropbox lock the file while one operation is being done on it? If not, I guess I have to handle it in my application correct?
Yes, you do have to worry about this.
Dropbox uses optimistic concurrency. Every file has a
rev
(revision) that you can reference when uploading a file (e.g. via/files_put
). So the basic idea is that when you download a file, you keep track of therev
, and when you upload the file, you pass thatrev
as theparent_rev
parameter. If the file has been changed in the meantime by a different user (via a shared folder) or the same user (via a different device), therev
won't match. What happens then is dictated by theautorename
parameter. If you specifytrue
, the file will get renamed on conflict. If you specifyfalse
, the upload will fail altogether, and your app can decide what to do.Essentially, you can't stop users from updating files simultaneously on multiple devices, but you can (and should) deal with these conflicts in your app, and the
rev
is what lets you ensure no data is lost.