Remove meta/mini records. Bye!

This commit is contained in:
Edward Lee 2009-08-13 18:50:54 -07:00
Родитель b2bd7b5d10
Коммит 5f6b7af2ff
3 изменённых файлов: 23 добавлений и 82 удалений

Просмотреть файл

@ -457,57 +457,39 @@ SyncEngine.prototype = {
if (outnum) { if (outnum) {
// collection we'll upload // collection we'll upload
let up = new Collection(this.engineURL); let up = new Collection(this.engineURL);
let meta = {}; let count = 0;
// Upload what we've got so far in the collection
let doUpload = Utils.bind2(this, function(desc) {
this._log.info("Uploading " + desc + " of " + outnum + " records");
up.post();
if (up.data.modified > this.lastSync)
this.lastSync = up.data.modified;
up.clearRecords();
});
// don't cache the outgoing items, we won't need them later // don't cache the outgoing items, we won't need them later
this._store.cache.enabled = false; this._store.cache.enabled = false;
let count = 0;
for (let id in this._tracker.changedIDs) { for (let id in this._tracker.changedIDs) {
let out = this._createRecord(id); let out = this._createRecord(id);
this._log.trace("Outgoing:\n" + out); this._log.trace("Outgoing:\n" + out);
// skip getting siblings of already processed and deleted records
if (!out.deleted && !(out.id in meta))
this._store.createMetaRecords(out.id, meta);
out.encrypt(ID.get("WeaveCryptoID")); out.encrypt(ID.get("WeaveCryptoID"));
up.pushData(JSON.parse(out.serialize())); // FIXME: inefficient up.pushData(JSON.parse(out.serialize())); // FIXME: inefficient
if ((++count % MAX_UPLOAD_RECORDS) == 0) { // Partial upload
// partial upload if ((++count % MAX_UPLOAD_RECORDS) == 0)
this._log.info("Uploading " + (count - MAX_UPLOAD_RECORDS) + " - " + doUpload((count - MAX_UPLOAD_RECORDS) + " - " + count + " out");
count + " out of " + outnum + " records");
up.post();
if (up.data.modified > this.lastSync)
this.lastSync = up.data.modified;
up.clearRecords();
}
Sync.sleep(0); Sync.sleep(0);
} }
// Final upload
if (count % MAX_UPLOAD_RECORDS > 0)
doUpload(count >= MAX_UPLOAD_RECORDS ? "last batch" : "all");
this._store.cache.enabled = true; this._store.cache.enabled = true;
// now add short depth-and-index-only records, except the ones we're
// sending as full records
let metaCount = 0;
for each (let obj in meta) {
if (!(obj.id in this._tracker.changedIDs)) {
up.pushData(obj);
metaCount++;
}
}
// final upload
if ((count % MAX_UPLOAD_RECORDS) + metaCount > 0) {
this._log.info("Uploading " +
(count >= MAX_UPLOAD_RECORDS? "last batch of " : "") +
count + " records, and " + metaCount + " index/depth records");
up.post();
if (up.data.modified > this.lastSync)
this.lastSync = up.data.modified;
}
} }
this._tracker.clearChangedIDs(); this._tracker.clearChangedIDs();
}, },

Просмотреть файл

@ -543,15 +543,6 @@ BookmarksStore.prototype = {
return record; return record;
}, },
_createMiniRecord: function BStore__createMiniRecord(placesId, depthIndex) {
let foo = {id: this._bms.getItemGUID(placesId)};
if (depthIndex) {
foo.depth = this._itemDepth(placesId);
foo.sortindex = this._bms.getItemIndex(placesId);
}
return foo;
},
_getWeaveParentIdForItem: function BStore__getWeaveParentIdForItem(itemId) { _getWeaveParentIdForItem: function BStore__getWeaveParentIdForItem(itemId) {
let parentid = this._bms.getFolderIdForItem(itemId); let parentid = this._bms.getFolderIdForItem(itemId);
if (parentid == -1) { if (parentid == -1) {
@ -562,9 +553,7 @@ BookmarksStore.prototype = {
return this._getWeaveIdForItem(parentid); return this._getWeaveIdForItem(parentid);
}, },
_getChildren: function BStore_getChildren(guid, depthIndex, items) { _getChildren: function BStore_getChildren(guid, items) {
if (typeof(items) == "undefined")
items = {};
let node = guid; // the recursion case let node = guid; // the recursion case
if (typeof(node) == "string") // callers will give us the guid as the first arg if (typeof(node) == "string") // callers will give us the guid as the first arg
node = this._getNode(this._getItemIdForGUID(guid)); node = this._getNode(this._getItemIdForGUID(guid));
@ -573,35 +562,18 @@ BookmarksStore.prototype = {
!this._ls.isLivemark(node.itemId)) { !this._ls.isLivemark(node.itemId)) {
node.QueryInterface(Ci.nsINavHistoryQueryResultNode); node.QueryInterface(Ci.nsINavHistoryQueryResultNode);
node.containerOpen = true; node.containerOpen = true;
// Remember all the children GUIDs and recursively get more
for (var i = 0; i < node.childCount; i++) { for (var i = 0; i < node.childCount; i++) {
let child = node.getChild(i); let child = node.getChild(i);
let foo = this._createMiniRecord(child.itemId, true); items[this._bms.getItemGUID(child.itemId)] = true;
items[foo.id] = foo; this._getChildren(child, items);
this._getChildren(child, depthIndex, items);
} }
} }
return items; return items;
}, },
_getSiblings: function BStore__getSiblings(guid, depthIndex, items) {
if (typeof(items) == "undefined")
items = {};
let parentid = this._bms.getFolderIdForItem(this._getItemIdForGUID(guid));
let parent = this._getNode(parentid);
parent.QueryInterface(Ci.nsINavHistoryQueryResultNode);
parent.containerOpen = true;
for (var i = 0; i < parent.childCount; i++) {
let child = parent.getChild(i);
let foo = this._createMiniRecord(child.itemId, true);
items[foo.id] = foo;
}
return items;
},
_tagURI: function BStore_tagURI(bmkURI, tags) { _tagURI: function BStore_tagURI(bmkURI, tags) {
// Filter out any null/undefined/empty tags // Filter out any null/undefined/empty tags
tags = tags.filter(function(t) t); tags = tags.filter(function(t) t);
@ -618,13 +590,7 @@ BookmarksStore.prototype = {
let items = {}; let items = {};
for (let [weaveId, id] in Iterator(kSpecialIds)) for (let [weaveId, id] in Iterator(kSpecialIds))
if (weaveId != "places" && weaveId != "tags") if (weaveId != "places" && weaveId != "tags")
this._getChildren(weaveId, true, items); this._getChildren(weaveId, items);
return items;
},
createMetaRecords: function BStore_createMetaRecords(guid, items) {
this._getChildren(guid, true, items);
this._getSiblings(guid, true, items);
return items; return items;
}, },

Просмотреть файл

@ -104,13 +104,6 @@ Store.prototype = {
throw "override createRecord in a subclass"; throw "override createRecord in a subclass";
}, },
// override if depth and/or depthindex are used
// should return all objects potentially affected by change of guid, in
// short form (no full content, only id, depth, sortindex)
createMetaRecords: function Store_createMetaRecords(guid, items) {
return {};
},
changeItemID: function Store_changeItemID(oldID, newID) { changeItemID: function Store_changeItemID(oldID, newID) {
throw "override changeItemID in a subclass"; throw "override changeItemID in a subclass";
}, },