migration from localStorage to fileStorege
This commit is contained in:
parent
f47d6b0564
commit
cf557fe018
4 changed files with 65 additions and 16 deletions
|
|
@ -47,6 +47,32 @@ angular.module('copayApp.services')
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
root.tryToMigrate = function(cb) {
|
||||
if (!isCordova) return cb();
|
||||
|
||||
localStorageService.get('profile', function(err, p) {
|
||||
if (err) cb(err);
|
||||
if (!p) return cb();
|
||||
$log.info('Starting Migration profile to File storage...')
|
||||
fileStorageService.create('profile', p, function(err) {
|
||||
if (err) cb(err);
|
||||
$log.info('Profile Migrated successfully');
|
||||
|
||||
localStorageService.get('config', function(err, c) {
|
||||
if (err) cb(err);
|
||||
if (!c) return cb(null, p);
|
||||
fileStorageService.create('config', c, function(err) {
|
||||
if (err) cb(err);
|
||||
$log.info('Config Migrated successfully');
|
||||
return cb(null, p)
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
root.storeNewProfile = function(profile, cb) {
|
||||
encryptOnMobile(profile.toObj(), function(err, x) {
|
||||
storage.create('profile', x, cb);
|
||||
|
|
@ -62,8 +88,8 @@ angular.module('copayApp.services')
|
|||
root.getProfile = function(cb) {
|
||||
storage.get('profile', function(err, str) {
|
||||
|
||||
if (err || !str)
|
||||
// Migrate ?
|
||||
if (err || !str)
|
||||
// Migrate ?
|
||||
return cb(err);
|
||||
|
||||
decryptOnMobile(str, function(err, str) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue