You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
All: Fixed handling of unloaded master key
This commit is contained in:
@ -274,7 +274,7 @@ class BaseApplication {
|
||||
const loadedMasterKeyIds = EncryptionService.instance().loadedMasterKeyIds();
|
||||
|
||||
this.dispatch({
|
||||
type: 'MASTERKEY_REMOVE_MISSING',
|
||||
type: 'MASTERKEY_REMOVE_NOT_LOADED',
|
||||
ids: loadedMasterKeyIds,
|
||||
});
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ const defaultState = {
|
||||
folders: [],
|
||||
tags: [],
|
||||
masterKeys: [],
|
||||
missingMasterKeys: [],
|
||||
notLoadedMasterKeys: [],
|
||||
searches: [],
|
||||
selectedNoteIds: [],
|
||||
selectedFolderId: null,
|
||||
@ -370,27 +370,27 @@ const reducer = (state = defaultState, action) => {
|
||||
newState.masterKeys = action.items;
|
||||
break;
|
||||
|
||||
case 'MASTERKEY_ADD_MISSING':
|
||||
case 'MASTERKEY_ADD_NOT_LOADED':
|
||||
|
||||
if (state.missingMasterKeys.indexOf(action.id) < 0) {
|
||||
if (state.notLoadedMasterKeys.indexOf(action.id) < 0) {
|
||||
newState = Object.assign({}, state);
|
||||
const keys = newState.missingMasterKeys.slice();
|
||||
const keys = newState.notLoadedMasterKeys.slice();
|
||||
keys.push(action.id);
|
||||
newState.missingMasterKeys = keys;
|
||||
newState.notLoadedMasterKeys = keys;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'MASTERKEY_REMOVE_MISSING':
|
||||
case 'MASTERKEY_REMOVE_NOT_LOADED':
|
||||
|
||||
const ids = action.id ? [action.id] : action.ids;
|
||||
for (let i = 0; i < ids.length; i++) {
|
||||
const id = ids[i];
|
||||
const index = state.missingMasterKeys.indexOf(id);
|
||||
const index = state.notLoadedMasterKeys.indexOf(id);
|
||||
if (index >= 0) {
|
||||
newState = Object.assign({}, state);
|
||||
const keys = newState.missingMasterKeys.slice();
|
||||
const keys = newState.notLoadedMasterKeys.slice();
|
||||
keys.splice(index, 1);
|
||||
newState.missingMasterKeys = keys;
|
||||
newState.notLoadedMasterKeys = keys;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -62,10 +62,10 @@ class DecryptionWorker {
|
||||
try {
|
||||
await ItemClass.decrypt(item);
|
||||
} catch (error) {
|
||||
if (error.code === 'missingMasterKey') {
|
||||
if (error.code === 'masterKeyNotLoaded') {
|
||||
excludedIds.push(item.id);
|
||||
this.dispatch({
|
||||
type: 'MASTERKEY_ADD_MISSING',
|
||||
type: 'MASTERKEY_ADD_NOT_LOADED',
|
||||
id: error.masterKeyId,
|
||||
});
|
||||
continue;
|
||||
|
@ -136,7 +136,7 @@ class EncryptionService {
|
||||
loadedMasterKey(id) {
|
||||
if (!this.loadedMasterKeys_[id]) {
|
||||
const error = new Error('Master key is not loaded: ' + id);
|
||||
error.code = 'missingMasterKey';
|
||||
error.code = 'masterKeyNotLoaded';
|
||||
error.masterKeyId = id;
|
||||
throw error;
|
||||
}
|
||||
|
Reference in New Issue
Block a user