Don't create a GUID when looking for dupes and set the GUID when adding a url.

This commit is contained in:
Edward Lee 2009-09-10 20:04:34 -07:00
parent 5944a1f90a
commit dc6d0cb84b

View File

@ -58,14 +58,15 @@ function setGUID(uri, guid) {
Utils.anno(uri, GUID_ANNO, guid, "WITH_HISTORY"); Utils.anno(uri, GUID_ANNO, guid, "WITH_HISTORY");
return guid; return guid;
} }
function GUIDForUri(uri) { function GUIDForUri(uri, create) {
try { try {
// Use the existing GUID if it exists // Use the existing GUID if it exists
return Utils.anno(uri, GUID_ANNO); return Utils.anno(uri, GUID_ANNO);
} }
catch (ex) { catch (ex) {
// Give the uri a GUID if it doesn't have one // Give the uri a GUID if it doesn't have one
return setGUID(uri); if (create)
return setGUID(uri);
} }
} }
@ -200,14 +201,16 @@ HistoryStore.prototype = {
let items = {}; let items = {};
for (let i = 0; i < root.childCount; i++) { for (let i = 0; i < root.childCount; i++) {
let item = root.getChild(i); let item = root.getChild(i);
let guid = GUIDForUri(item.uri); let guid = GUIDForUri(item.uri, true);
items[guid] = item.uri; items[guid] = item.uri;
} }
return items; return items;
}, },
create: function HistStore_create(record) { create: function HistStore_create(record) {
// Add the url and set the GUID
this.update(record); this.update(record);
setGUID(record.histUri, record.id);
}, },
remove: function HistStore_remove(record) { remove: function HistStore_remove(record) {
@ -311,7 +314,7 @@ HistoryTracker.prototype = {
if (this.ignoreAll) if (this.ignoreAll)
return; return;
this._log.trace("onVisit: " + uri.spec); this._log.trace("onVisit: " + uri.spec);
if (this.addChangedID(GUIDForUri(uri))) if (this.addChangedID(GUIDForUri(uri, true)))
this._upScore(); this._upScore();
}, },
onPageExpired: function HT_onPageExpired(uri, time, entry) { onPageExpired: function HT_onPageExpired(uri, time, entry) {