If you succeed, the easiest way to sync (today) is to have three copies of your data locally: the copy you downloaded last (the “old”), the copy made by the local changes (“mine”), and the copy is now loaded with server ("their").
Then sort all the entries in all three files and go one by one:
- if old == mine, use them
- else if old == them use my
- otherwise you have a conflict; something like that (for example, always use mine, aka "the last writer wins")
Please note that “mine” or “their” or “old” may not exist. The above rules still apply in this case; if the result you select does not exist, you will want to delete the entry in the output file.
Finally, upload the resulting file back to the server so that it becomes “your” base for the next guy. Then copy the new file to the local "old" and "my" databases.
(There are more space-efficient algorithms than mentioned above ... but there are no simpler ones :) And disk space these days is pretty cheap, especially if you compress files.)
apenwarr
source share