1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-12 22:57:38 +02:00

All: Fixed various issues regarding encryption and decryptino of resources, and started doing GUI for Electron app

This commit is contained in:
Laurent Cozic
2017-12-21 20:06:08 +01:00
parent 7750b954fc
commit 6683da804b
12 changed files with 81 additions and 89 deletions

View File

@ -181,6 +181,7 @@ class Synchronizer {
this.cancelling_ = false;
const masterKeysBefore = await MasterKey.count();
let hasAutoEnabledEncryption = false;
// ------------------------------------------------------------------------
// First, find all the items that have been changed since the
@ -508,6 +509,17 @@ class Synchronizer {
await ItemClass.save(content, options);
if (!hasAutoEnabledEncryption && content.type_ === BaseModel.TYPE_MASTER_KEY && !masterKeysBefore) {
hasAutoEnabledEncryption = true;
this.logger().info('One master key was downloaded and none was previously available: automatically enabling encryption');
this.logger().info('Using master key: ', content);
await this.encryptionService().enableEncryption(content);
await this.encryptionService().loadMasterKeysFromSettings();
this.logger().info('Encryption has been enabled with downloaded master key as active key. However, note that no password was initially supplied. It will need to be provided by user.');
}
if (!!content.encryption_applied) this.dispatch({ type: 'SYNC_GOT_ENCRYPTED_ITEM' });
} else if (action == 'deleteLocal') {
if (local.type_ == BaseModel.TYPE_FOLDER) {
@ -575,23 +587,6 @@ class Synchronizer {
this.cancelling_ = false;
}
const masterKeysAfter = await MasterKey.count();
if (!masterKeysBefore && masterKeysAfter) {
this.logger().info('One master key was downloaded and none was previously available: automatically enabling encryption');
const mk = await MasterKey.latest();
if (mk) {
this.logger().info('Using master key: ', mk);
await this.encryptionService().enableEncryption(mk);
await this.encryptionService().loadMasterKeysFromSettings();
this.logger().info('Encryption has been enabled with downloaded master key as active key. However, note that no password was initially supplied. It will need to be provided by user.');
}
}
if (masterKeysAfter && this.autoStartDecryptionWorker_) {
DecryptionWorker.instance().scheduleStart();
}
this.progressReport_.completedTime = time.unixMs();
this.logSyncOperation('finished', null, null, 'Synchronisation finished [' + synchronizationId + ']');