fix opening corrupt profiles
This commit is contained in:
parent
f1e67ad0e6
commit
f244462250
1 changed files with 17 additions and 1 deletions
|
|
@ -28,7 +28,23 @@ angular.module('copayApp.services')
|
|||
var json;
|
||||
try {
|
||||
json = JSON.parse(text);
|
||||
} catch (e) {};
|
||||
} catch (e) {
|
||||
$log.warn('Could not open profile:' + text);
|
||||
|
||||
var i = text.lastIndexOf('}{');
|
||||
if (i > 0) {
|
||||
text = text.substr(i + 1);
|
||||
$log.warn('trying last part only:' + text);
|
||||
try {
|
||||
json = JSON.parse(text);
|
||||
$log.warn('Worked... saving.');
|
||||
storage.set('profile', text, function() {});
|
||||
} catch (e) {
|
||||
$log.warn('Could not open profile (2nd try):' + e);
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
if (!json) return cb('Could not access storage')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue