mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-19 07:54:59 +01:00
Fix event index passphrase change process
This commit is contained in:
parent
5ae736e861
commit
3f9495f19d
@ -100,6 +100,12 @@ if (argv["help"]) {
|
|||||||
app.exit();
|
app.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function delay(timeout) {
|
||||||
|
return new Promise(res => {
|
||||||
|
setTimeout(() => res(), timeout);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Electron creates the user data directory (with just an empty 'Dictionaries' directory...)
|
// Electron creates the user data directory (with just an empty 'Dictionaries' directory...)
|
||||||
// as soon as the app path is set, so pick a random path in it that must exist if it's a
|
// as soon as the app path is set, so pick a random path in it that must exist if it's a
|
||||||
// real user data directory.
|
// real user data directory.
|
||||||
@ -596,8 +602,15 @@ ipcMain.on('seshat', async function(ev, payload) {
|
|||||||
// index.
|
// index.
|
||||||
await eventIndex.changePassphrase(newPassphrase);
|
await eventIndex.changePassphrase(newPassphrase);
|
||||||
|
|
||||||
|
// Keep this delay to avoid race conditions where the DB
|
||||||
|
// lock has not been released properly when trying to
|
||||||
|
// create a new event index
|
||||||
|
await delay(500);
|
||||||
|
|
||||||
// Re-open the event index with the new passphrase.
|
// Re-open the event index with the new passphrase.
|
||||||
eventIndex = new Seshat(eventStorePath, {newPassphrase});
|
eventIndex = new Seshat(eventStorePath, {
|
||||||
|
passphrase: newPassphrase,
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendError(payload.id, e);
|
sendError(payload.id, e);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user