Foxmarks: Top Level Algorithm
From Foxmarks Wiki
Here's what happens when synchronization starts, either because the user pressed the "Synchronize Now" button or the hot sync key, or automatic synchronization is invoked.
First, we attempt a conditional download of the remote sync file. There are four potential responses.
- Got the file.
- The file is unmodified.
- The file is not found.
- Some other network error.
What happens next depends largely on whether we've sync'd before. First, take the case where we haven't synced (to the current server settings) before.
- Got the file: invoke the "Initial Sync" dialog to get the user's input about how to proceed.
- File is unmodified: this is unexpected. We should never get this response in this context.
- File is not found: silently copy local to remote.
- Other error: report the error to the user and stop.
If we have synced previously:
- Got the file: remote is probably dirty. Perform the sync. Write the results only if local was dirty. Copy back to local only if remote was dirty.
- File is unmodified: remote is clean. If local is clean, too, exit. If local is dirty, copy local to remote.
- There is a problem here. If we copy local to remote, everything on the server will be dirtied. Ideally, we want only to dirty those items that were dirty on local. To do this, we'd have to modify our copy routine a bit.
- Done.
- File is not found: alert the user. If they approve, copy local to remote.
- Other error: report the error and stop.
