зеркало из https://github.com/mozilla/gecko-dev.git
Remove meta/mini records. Bye!
This commit is contained in:
Родитель
b2bd7b5d10
Коммит
5f6b7af2ff
|
@ -457,57 +457,39 @@ SyncEngine.prototype = {
|
|||
if (outnum) {
|
||||
// collection we'll upload
|
||||
let up = new Collection(this.engineURL);
|
||||
let meta = {};
|
||||
|
||||
// don't cache the outgoing items, we won't need them later
|
||||
this._store.cache.enabled = false;
|
||||
|
||||
let count = 0;
|
||||
for (let id in this._tracker.changedIDs) {
|
||||
let out = this._createRecord(id);
|
||||
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"));
|
||||
up.pushData(JSON.parse(out.serialize())); // FIXME: inefficient
|
||||
|
||||
if ((++count % MAX_UPLOAD_RECORDS) == 0) {
|
||||
// partial upload
|
||||
this._log.info("Uploading " + (count - MAX_UPLOAD_RECORDS) + " - " +
|
||||
count + " out of " + outnum + " records");
|
||||
// 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
|
||||
this._store.cache.enabled = false;
|
||||
|
||||
for (let id in this._tracker.changedIDs) {
|
||||
let out = this._createRecord(id);
|
||||
this._log.trace("Outgoing:\n" + out);
|
||||
|
||||
out.encrypt(ID.get("WeaveCryptoID"));
|
||||
up.pushData(JSON.parse(out.serialize())); // FIXME: inefficient
|
||||
|
||||
// Partial upload
|
||||
if ((++count % MAX_UPLOAD_RECORDS) == 0)
|
||||
doUpload((count - MAX_UPLOAD_RECORDS) + " - " + count + " out");
|
||||
|
||||
Sync.sleep(0);
|
||||
}
|
||||
|
||||
// Final upload
|
||||
if (count % MAX_UPLOAD_RECORDS > 0)
|
||||
doUpload(count >= MAX_UPLOAD_RECORDS ? "last batch" : "all");
|
||||
|
||||
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();
|
||||
},
|
||||
|
|
|
@ -543,15 +543,6 @@ BookmarksStore.prototype = {
|
|||
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) {
|
||||
let parentid = this._bms.getFolderIdForItem(itemId);
|
||||
if (parentid == -1) {
|
||||
|
@ -562,9 +553,7 @@ BookmarksStore.prototype = {
|
|||
return this._getWeaveIdForItem(parentid);
|
||||
},
|
||||
|
||||
_getChildren: function BStore_getChildren(guid, depthIndex, items) {
|
||||
if (typeof(items) == "undefined")
|
||||
items = {};
|
||||
_getChildren: function BStore_getChildren(guid, items) {
|
||||
let node = guid; // the recursion case
|
||||
if (typeof(node) == "string") // callers will give us the guid as the first arg
|
||||
node = this._getNode(this._getItemIdForGUID(guid));
|
||||
|
@ -573,35 +562,18 @@ BookmarksStore.prototype = {
|
|||
!this._ls.isLivemark(node.itemId)) {
|
||||
node.QueryInterface(Ci.nsINavHistoryQueryResultNode);
|
||||
node.containerOpen = true;
|
||||
|
||||
// Remember all the children GUIDs and recursively get more
|
||||
for (var i = 0; i < node.childCount; i++) {
|
||||
let child = node.getChild(i);
|
||||
let foo = this._createMiniRecord(child.itemId, true);
|
||||
items[foo.id] = foo;
|
||||
this._getChildren(child, depthIndex, items);
|
||||
items[this._bms.getItemGUID(child.itemId)] = true;
|
||||
this._getChildren(child, 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) {
|
||||
// Filter out any null/undefined/empty tags
|
||||
tags = tags.filter(function(t) t);
|
||||
|
@ -618,13 +590,7 @@ BookmarksStore.prototype = {
|
|||
let items = {};
|
||||
for (let [weaveId, id] in Iterator(kSpecialIds))
|
||||
if (weaveId != "places" && weaveId != "tags")
|
||||
this._getChildren(weaveId, true, items);
|
||||
return items;
|
||||
},
|
||||
|
||||
createMetaRecords: function BStore_createMetaRecords(guid, items) {
|
||||
this._getChildren(guid, true, items);
|
||||
this._getSiblings(guid, true, items);
|
||||
this._getChildren(weaveId, items);
|
||||
return items;
|
||||
},
|
||||
|
||||
|
|
|
@ -104,13 +104,6 @@ Store.prototype = {
|
|||
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) {
|
||||
throw "override changeItemID in a subclass";
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче