--- a/services/sync/modules/base_records/wbo.js
+++ b/services/sync/modules/base_records/wbo.js
@@ -29,17 +29,17 @@
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
-const EXPORTED_SYMBOLS = ['WBORecord', 'RecordManager'];
+const EXPORTED_SYMBOLS = ['WBORecord', 'RecordManager', 'Records'];
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://weave/log4moz.js");
Cu.import("resource://weave/resource.js");
@@ -133,16 +133,18 @@ WBORecord.prototype = {
return "{ id: " + this.id + "\n" +
" parent: " + this.parentid + "\n" +
" depth: " + this.depth + ", index: " + this.sortindex + "\n" +
" modified: " + this.modified + "\n" +
" payload: " + Svc.Json.encode(this.payload) + " }";
}
};
+Utils.lazy(this, 'Records', RecordManager);
+
function RecordManager() {
this._init();
}
RecordManager.prototype = {
_recordType: WBORecord,
_logName: "RecordMgr",
_init: function RegordMgr__init() {
@@ -154,22 +156,22 @@ RecordManager.prototype = {
import: function RegordMgr_import(onComplete, url) {
let fn = function RegordMgr__import(url) {
let self = yield;
let record;
this._log.trace("Importing record: " + (url.spec? url.spec : url));
try {
- let rsrc = new Resource(url);
- yield rsrc.get(self.cb);
+ this.lastResource = new Resource(url);
+ yield this.lastResource.get(self.cb);
record = new this._recordType();
- record.deserialize(rsrc.data);
- record.uri = url; // NOTE: may override id in rsrc.data
+ record.deserialize(this.lastResource.data);
+ record.uri = url; // NOTE: may override id in this.lastResource.data
this.set(url, record);
} catch (e) {
this._log.debug("Failed to import record: " + e);
record = null;
}
self.done(record);
};