Dropbox, thank you!!!

Man, I sorely wanted the ability to upload a new version of a file, but only have it overrwrite the previous version if the previous version was the one I thought, as opposed to someone else having put a newer version there between when I read the file and now.

And it didn't seem like they had it. The writeFile method had a lastVersionTag option that it just said was "used for conflict resolution", but I wasn't sure what that meant, and I should have tried it out, but I assumed the net result was successfully overwriting the file.

But I discovered, from the documentation for a non-JavaScript version of the API, that if the lastVersionTag didn't match, dropbox would NOT overwrite the file, but rather add the uploaded file to the same directory as a conflicted version.

Anyway, yay! I'm so happy.. I almost resorted to writing code that could have lost data, after writing code that was sure to not lose data, but involved creating a "lock" file, and was slow, complicated, probably buggy, and vulnerable to either a slight chance of deadlock or a slight chance of inconsistency.. all my options seemed dirty and complicated.

No comments:

Post a Comment