|
|
@ -99,54 +99,52 @@
|
|
|
|
this.trigger('cancel');
|
|
|
|
this.trigger('cancel');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onImport: function() {
|
|
|
|
onImport: function() {
|
|
|
|
|
|
|
|
Whisper.Backup.getDirectoryForImport().then(function(directory) {
|
|
|
|
|
|
|
|
this.doImport(directory);
|
|
|
|
|
|
|
|
}.bind(this), function(error) {
|
|
|
|
|
|
|
|
if (error.name !== 'ChooseError') {
|
|
|
|
|
|
|
|
console.log('Error choosing directory:', error && error.stack ? error.stack : error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
doImport: function(directory) {
|
|
|
|
this.error = null;
|
|
|
|
this.error = null;
|
|
|
|
|
|
|
|
|
|
|
|
this.state = State.IMPORTING;
|
|
|
|
this.state = State.IMPORTING;
|
|
|
|
this.render();
|
|
|
|
this.render();
|
|
|
|
|
|
|
|
|
|
|
|
var importLocation;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Wait for prior database interaction to complete
|
|
|
|
// Wait for prior database interaction to complete
|
|
|
|
this.pending = this.pending.then(function() {
|
|
|
|
this.pending = this.pending.then(function() {
|
|
|
|
// For resilience to interruptions, clear database both before import and after
|
|
|
|
// For resilience to interruptions, clear database both before import and after
|
|
|
|
return Whisper.Backup.clearDatabase();
|
|
|
|
return Whisper.Backup.clearDatabase();
|
|
|
|
}).then(function() {
|
|
|
|
}).then(function() {
|
|
|
|
Whisper.Import.start();
|
|
|
|
Whisper.Import.start();
|
|
|
|
return Whisper.Backup.importFromDirectory();
|
|
|
|
return Whisper.Backup.importFromDirectory(directory);
|
|
|
|
}).then(function(directory) {
|
|
|
|
}).then(function() {
|
|
|
|
importLocation = directory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Catching in-memory cache up with what's in indexeddb now...
|
|
|
|
// Catching in-memory cache up with what's in indexeddb now...
|
|
|
|
// NOTE: this fires storage.onready, listened to across the app. We'll restart
|
|
|
|
// NOTE: this fires storage.onready, listened to across the app. We'll restart
|
|
|
|
// to complete the install to start up cleanly with everything now in the DB.
|
|
|
|
// to complete the install to start up cleanly with everything now in the DB.
|
|
|
|
return storage.fetch();
|
|
|
|
return storage.fetch();
|
|
|
|
}).then(function() {
|
|
|
|
}).then(function() {
|
|
|
|
// Clearing any migration-related state inherited from the Chome App
|
|
|
|
// Clearing any migration-related state inherited from the Chrome App
|
|
|
|
storage.remove('migrationState');
|
|
|
|
storage.remove('migrationState');
|
|
|
|
storage.remove('migrationEnabled');
|
|
|
|
storage.remove('migrationEnabled');
|
|
|
|
storage.remove('migrationEverCompleted');
|
|
|
|
storage.remove('migrationEverCompleted');
|
|
|
|
storage.remove('migrationStorageLocation');
|
|
|
|
storage.remove('migrationStorageLocation');
|
|
|
|
|
|
|
|
|
|
|
|
if (importLocation) {
|
|
|
|
Whisper.Import.saveLocation(directory);
|
|
|
|
Whisper.Import.saveLocation(importLocation);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Whisper.Import.complete();
|
|
|
|
Whisper.Import.complete();
|
|
|
|
|
|
|
|
|
|
|
|
this.state = State.COMPLETE;
|
|
|
|
this.state = State.COMPLETE;
|
|
|
|
this.render();
|
|
|
|
this.render();
|
|
|
|
}.bind(this)).catch(function(error) {
|
|
|
|
}.bind(this)).catch(function(error) {
|
|
|
|
if (error.name !== 'ChooseError') {
|
|
|
|
|
|
|
|
this.error = error.message;
|
|
|
|
|
|
|
|
console.log('Error importing:', error && error.stack ? error.stack : error);
|
|
|
|
console.log('Error importing:', error && error.stack ? error.stack : error);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.error = error.message;
|
|
|
|
this.state = null;
|
|
|
|
this.state = null;
|
|
|
|
this.render();
|
|
|
|
this.render();
|
|
|
|
|
|
|
|
|
|
|
|
if (this.error) {
|
|
|
|
|
|
|
|
return Whisper.Backup.clearDatabase();
|
|
|
|
return Whisper.Backup.clearDatabase();
|
|
|
|
}
|
|
|
|
|
|
|
|
}.bind(this));
|
|
|
|
}.bind(this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|