Storing the backup flag

This commit is contained in:
Matias Pando 2014-11-26 12:08:26 -03:00
commit 52fb680658
6 changed files with 34 additions and 98 deletions

View file

@ -274,10 +274,17 @@ Identity.prototype.toObj = function() {
Identity.prototype.exportEncryptedWithWalletInfo = function(opts) {
var crypto = opts.cryptoUtil || cryptoUtil;
this.backupNeeded = false;
return crypto.encrypt(this.password, this.exportWithWalletInfo(opts));
};
Identity.prototype.setBackupDone = function() {
this.backupNeeded = false;
this.store({
noWallets: true
}, function() {});
}
Identity.prototype.exportWithWalletInfo = function(opts) {
return _.extend({
wallets: _.map(this.wallets, function(wallet) {
@ -295,12 +302,13 @@ Identity.prototype.exportWithWalletInfo = function(opts) {
Identity.prototype.store = function(opts, cb) {
var self = this;
opts = opts || {};
opts.backupNeeded = false;
var storeFunction = opts.failIfExists ? self.storage.createItem : self.storage.setItem;
storeFunction.call(self.storage, this.getId(), this.toObj(), function(err) {
if (err) return cb(err);
if (err) {
return cb(err);
}
if (opts.noWallets)
return cb();