The Need for Adjustments
Not all browsers and services allow bookmarks to be stored in the same way. In Bookdog, each bookmarks document is wysiwyg (what you see is what you get) with respect to the browser or service. For example, Camino does not allow loose bookmarks at its root level. It only allows folders. Therefore, if a user drags, migrates, moves or copies some loose bookmarks into the root level of a Camino document in Bookdog, knowing that these are Camino bookmarks, Bookdog retargets them during the drop to the Bookmarks Menu of the Camino document, and the user is immediately aware of the issue.
This wysiwyg behavior, while nice, is not be available in the bookmarks book, because it is an independent document, not restricted by the requirements of any particular browser or service. The moves or other adjustments necessary to satisfy the destination browser or service will be made during Sync Out, and will not be shown to the user until the user launches the browser or service and sees the result.
Sync In and Sync Out Process Details
Sync In is a two-step process internally. First, the data is read in from the external browser or service to an external managed object context. Second, it is internalized from there into the bookmark book's document managed object context, making any adjustments that are required or specified.
Sync Out is a three-step process internally. The first step is externalize items from the bookmark book's document managed object context into the external managed object context, again using the old migrate routine to make whatever adjustments are necessary. The next step is to actually write out the data. For browser/services with atomic stores, this means to simply overwrite the old file. For browser/services with nonatomic stores such as Firefox 3 or any online service, this means to compare/insert/update/delete items on the server or in the database to match the items in the external managed object context. The third step, required for browsers or services which assigns external identifiers to new which are unpredictable, is to retrieve from the browser or service the external identifiers it assigned to any new items, and backfill those into the bookmarks book.
Some of the adjustments are optional. For example, when syncing in from a browser that does not support tags, some may want tags to be added to items based on their folder lineage. The bookmarks book window will have a tab for configuring these options. These options are generally those that are in the Translating tab of Bookdog's Preferences window.
Merging
Since Bookdog has no sense that the bookmark to "Apple" which it saw in your Safari bookmarks last week is the same bookmark to "Apple" that it sees in your Safari bookmarks today (unless you had given this bookmark special, extended properties), the only thing it compares is the URL, and it has only two choices when resolving a conflict: Either keep this one, or keep that one. When MERGE is selected as an option in Bookdogs Migration document, the user therefore gets a further option to Select which browser's items to favor when consolidating folders and avoiding duplicate bookmarks. It was a necessary design exercise for me to consider all possible use cases, but I would bet that the number of users who ever actually read the documentation or thought hard enough to actually understand what that option really does is probably about six or seven.
Several features of the new application allow this horrendous option to be removed:
- knows the unique identifier of every bookmark.
- reads the bookmarks it is about to overwrite before overwriting them.
- handles bookmarks asymmetrically, in its own context instead of wysiwyg-ing other applications.
- can merge the properties of individual items instead of just deleting one and keeping the other.
Avoiding Unnecessary Processing
New application
Browser Service Profiles
To perform a Sync In or Sync Out operations, the new application needs to identify the path, file format, and protocols required to access the external store, which is the source of data for a Sync In command or the destination of data for a Sync Out command. Physically, the external store is a file or directory, on a local drive or, for web services, on a remote server. The information about the external store is stored in a data object called a browser service profile. The attributes in this object are:
- External Store Format (exformat). This tells the application or worker what file format or API to use. Examples: Safari, Firefox, Delicious.
- Profile name. This is for browser names that have user profiles. Currently only Firefox uses this attribute.
- Store media. This identifies where to get the data. Possible values are: relative to user's home folder, relative to other user's home folder (possibly on other Mac), relative to remote server, relative to startup volume root.
- Other Mac Account This is required for other Mac account sources or destinations; bookmarks owned by desktop browsers on other accounts or networked accounts.
- Other Mac Volume This is optional, for other Mac account sources or destinations. It is used when bookmarks were accessed by mounting the root level of a networked hard drive.
- Standalone path. This is required for standalone sources or destinations. These are "loose" bookmarks files. Although they were created using the file format of a particular browser and thus have a browser or service name, are not known to that browser.
Jerry Krinock