bug 346818: make sure microsummary bookmark records in the bookmarks datastore really exist (i.e. they aren't for cut or deleted bookmarks, which don't get completely removed from the datastore until restart) so we don't hit an error when trying to update them; also, trap errors when updating microsummary bookmarks, so an exception for one update doesn't hork the rest of them; finally, add microsummary properties to the bookmark transaction manager, so they get saved and restored the way they are supposed to be saved and restored when bookmarks are cut and pasted

r=mconnor
This commit is contained in:
myk%mozilla.org 2006-08-24 22:30:07 +00:00
parent e356cbee97
commit 1964f70a1e
3 changed files with 31 additions and 6 deletions

View File

@ -146,7 +146,10 @@ function initServices()
RDF.GetResource(gNC_NS+"ShortcutURL"),
RDF.GetResource(gNC_NS+"Description"),
RDF.GetResource(gNC_NS+"WebPanel"),
RDF.GetResource(gNC_NS+"FeedURL")];
RDF.GetResource(gNC_NS+"FeedURL"),
RDF.GetResource(gNC_NS+"MicsumGenURI"),
RDF.GetResource(gNC_NS+"MicsumExpiration"),
RDF.GetResource(gNC_NS+"GeneratedTitle")];
gBkmkTxnSvc = Components.classes["@mozilla.org/bookmarks/transactionmanager;1"]
.getService(Components.interfaces.nsIBookmarkTransactionManager);
}
@ -477,7 +480,7 @@ var BookmarksCommand = {
// (if the selection is folder or livemark save all childs property)
var aType = BookmarksUtils.resolveType(aSelection.item[i]);
if (aType == "Livemark") {
sBookmarkItem += "\n\n\n\n\n\n"; // don't change livemark properties
sBookmarkItem += "\n\n\n\n\n\n\n\n\n"; // don't change livemark properties
} else {
for (var j = 0; j < gBmProperties.length; ++j) {
var itemValue = BMDS.GetTarget(aSelection.item[i], gBmProperties[j], true);

View File

@ -138,7 +138,10 @@ function bookmarkTransactionManager() {
rdfService.GetResource("http://home.netscape.com/NC-rdf#ShortcutURL"),
rdfService.GetResource("http://home.netscape.com/NC-rdf#Description"),
rdfService.GetResource("http://home.netscape.com/NC-rdf#WebPanel"),
rdfService.GetResource("http://home.netscape.com/NC-rdf#FeedURL")];
rdfService.GetResource("http://home.netscape.com/NC-rdf#FeedURL"),
rdfService.GetResource("http://home.netscape.com/NC-rdf#MicsumGenURI"),
rdfService.GetResource("http://home.netscape.com/NC-rdf#MicsumExpiration"),
rdfService.GetResource("http://home.netscape.com/NC-rdf#GeneratedTitle")];
function bkmkInsertTxn(aAction) {
this.type = "insert";

View File

@ -257,7 +257,14 @@ MicrosummaryService.prototype = {
// we don't try it every 15 seconds, potentially overloading the server.
this._setField(bookmarkID, FIELD_MICSUM_EXPIRATION, now + updateInterval);
this.refreshMicrosummary(bookmarkID);
// Try to update the microsummary, but trap errors, so an update
// that throws doesn't prevent us from updating the rest of them.
try {
this.refreshMicrosummary(bookmarkID);
}
catch(ex) {
Components.utils.reportError(ex);
}
}
},
@ -711,8 +718,18 @@ MicrosummaryService.prototype = {
var resources = this._bmds.GetSources(this._resource(FIELD_RDF_TYPE),
this._resource(VALUE_MICSUM_BOOKMARK),
true);
while (resources.hasMoreElements())
bookmarks.push(resources.getNext().QueryInterface(Ci.nsIRDFResource));
while (resources.hasMoreElements()) {
var resource = resources.getNext().QueryInterface(Ci.nsIRDFResource);
// When a bookmark gets deleted or cut, most of its arcs get removed
// from the data source, but a few of them remain, in particular its RDF
// type arc. So just because this resource has a MicsumBookmark type,
// that doesn't mean it's a real bookmark! We need to check.
if (!this._bms.isBookmarkedResource(resource))
continue;
bookmarks.push(resource);
}
return bookmarks;
},
@ -1001,6 +1018,8 @@ MicrosummaryService.prototype = {
throw "bookmark " + bookmarkID + " does not have a microsummary";
var pageURI = this._getPageForBookmark(bookmarkID);
if (!pageURI)
throw("can't get URL for bookmark with ID " + bookmarkID);
var generatorURI = this._uri(this._getField(bookmarkID, FIELD_MICSUM_GEN_URI));
var localGenerator = this._localGenerators[generatorURI.spec];