mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
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:
parent
e356cbee97
commit
1964f70a1e
@ -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);
|
||||
|
@ -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";
|
||||
|
@ -257,8 +257,15 @@ MicrosummaryService.prototype = {
|
||||
// we don't try it every 15 seconds, potentially overloading the server.
|
||||
this._setField(bookmarkID, FIELD_MICSUM_EXPIRATION, now + updateInterval);
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_updateMicrosummary: function MSS__updateMicrosummary(bookmarkID, microsummary) {
|
||||
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user