mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-30 10:36:35 +02:00
Desktop, Mobile: Fixes #5391: Fixed crash when a required master key does not exist
This commit is contained in:
parent
ad51090cdb
commit
dec0a08954
@ -1,4 +1,4 @@
|
||||
import { afterAllCleanUp, setupDatabaseAndSynchronizer, switchClient, encryptionService } from '../../testing/test-utils';
|
||||
import { afterAllCleanUp, setupDatabaseAndSynchronizer, switchClient, encryptionService, expectNotThrow } from '../../testing/test-utils';
|
||||
import MasterKey from '../../models/MasterKey';
|
||||
import { showMissingMasterKeyMessage } from './utils';
|
||||
import { localSyncInfo, setMasterKeyEnabled } from '../synchronizer/syncInfoUtils';
|
||||
@ -34,6 +34,8 @@ describe('e2ee/utils', function() {
|
||||
setMasterKeyEnabled(mk2.id, true);
|
||||
expect(showMissingMasterKeyMessage(localSyncInfo(), [mk1.id, mk2.id])).toBe(true);
|
||||
|
||||
await expectNotThrow(async () => showMissingMasterKeyMessage(localSyncInfo(), ['not_downloaded_yet']));
|
||||
|
||||
const syncInfo = localSyncInfo();
|
||||
syncInfo.masterKeys = [];
|
||||
expect(showMissingMasterKeyMessage(syncInfo, [mk1.id, mk2.id])).toBe(false);
|
||||
|
@ -98,6 +98,14 @@ export function showMissingMasterKeyMessage(syncInfo: SyncInfo, notLoadedMasterK
|
||||
|
||||
for (let i = notLoadedMasterKeys.length - 1; i >= 0; i--) {
|
||||
const mk = syncInfo.masterKeys.find(mk => mk.id === notLoadedMasterKeys[i]);
|
||||
|
||||
// A "notLoadedMasterKey" is a key that either doesn't exist or for
|
||||
// which a password hasn't been set yet. For the purpose of this
|
||||
// function, we only want to notify the user about unset passwords.
|
||||
// Master keys that haven't been downloaded yet should normally be
|
||||
// downloaded at some point.
|
||||
// https://github.com/laurent22/joplin/issues/5391
|
||||
if (!mk) continue;
|
||||
if (!masterKeyEnabled(mk)) notLoadedMasterKeys.pop();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user