mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-18 23:44:59 +01:00
electron-main: Skip the reindex if we're going to delete the db anyways.
This commit is contained in:
parent
748f4dccb4
commit
141107c678
@ -207,6 +207,14 @@ let eventIndex = null;
|
|||||||
let mainWindow = null;
|
let mainWindow = null;
|
||||||
global.appQuitting = false;
|
global.appQuitting = false;
|
||||||
|
|
||||||
|
|
||||||
|
const deleteFolderRecursive = async (p) => {
|
||||||
|
for (const entry of await afs.readdir(p)) {
|
||||||
|
const curPath = path.join(p, entry);
|
||||||
|
await afs.unlink(curPath);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// handle uncaught errors otherwise it displays
|
// handle uncaught errors otherwise it displays
|
||||||
// stack traces in popup dialogs, which is terrible (which
|
// stack traces in popup dialogs, which is terrible (which
|
||||||
// it will do any time the auto update poke fails, and there's
|
// it will do any time the auto update poke fails, and there's
|
||||||
@ -453,7 +461,22 @@ ipcMain.on('seshat', async function(ev, payload) {
|
|||||||
const recoveryIndex = new SeshatRecovery(eventStorePath, {
|
const recoveryIndex = new SeshatRecovery(eventStorePath, {
|
||||||
passphrase: seshatPassphrase,
|
passphrase: seshatPassphrase,
|
||||||
});
|
});
|
||||||
await recoveryIndex.reindex();
|
|
||||||
|
const userVersion = await recoveryIndex.getUserVersion();
|
||||||
|
|
||||||
|
// If our user version is 0 we'll delete the db
|
||||||
|
// anyways so reindexing it is a waste of time.
|
||||||
|
if (userVersion === 0) {
|
||||||
|
await recoveryIndex.shutdown();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await deleteFolderRecursive(eventStorePath);
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await recoveryIndex.reindex();
|
||||||
|
}
|
||||||
|
|
||||||
eventIndex = new Seshat(eventStorePath, {
|
eventIndex = new Seshat(eventStorePath, {
|
||||||
passphrase: seshatPassphrase,
|
passphrase: seshatPassphrase,
|
||||||
});
|
});
|
||||||
@ -485,13 +508,6 @@ ipcMain.on('seshat', async function(ev, payload) {
|
|||||||
|
|
||||||
case 'deleteEventIndex':
|
case 'deleteEventIndex':
|
||||||
{
|
{
|
||||||
const deleteFolderRecursive = async (p) => {
|
|
||||||
for (const entry of await afs.readdir(p)) {
|
|
||||||
const curPath = path.join(p, entry);
|
|
||||||
await afs.unlink(curPath);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await deleteFolderRecursive(eventStorePath);
|
await deleteFolderRecursive(eventStorePath);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user