mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-31 05:29:58 +01:00
Merge pull request #1916 from element-hq/langleyd/fix_seshat_delete_contents
Improve seshat deleteContents
This commit is contained in:
commit
838cf3bd30
@ -60,9 +60,17 @@ async function getOrCreatePassphrase(key: string): Promise<string> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deleteContents = async (p: string): Promise<void> => {
|
const deleteContents = async (p: string): Promise<void> => {
|
||||||
for (const entry of await afs.readdir(p)) {
|
try {
|
||||||
const curPath = path.join(p, entry);
|
for (const entry of await afs.readdir(p)) {
|
||||||
await afs.unlink(curPath);
|
const curPath = path.join(p, entry);
|
||||||
|
try {
|
||||||
|
await afs.unlink(curPath);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Error deleting a file in EventStore directory", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Error reading the files in EventStore directory", e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -115,10 +123,7 @@ ipcMain.on("seshat", async function (_ev: IpcMainEvent, payload): Promise<void>
|
|||||||
// anyways so reindexing it is a waste of time.
|
// anyways so reindexing it is a waste of time.
|
||||||
if (userVersion === 0) {
|
if (userVersion === 0) {
|
||||||
await recoveryIndex.shutdown();
|
await recoveryIndex.shutdown();
|
||||||
|
await deleteContents(eventStorePath);
|
||||||
try {
|
|
||||||
await deleteContents(eventStorePath);
|
|
||||||
} catch {}
|
|
||||||
} else {
|
} else {
|
||||||
await recoveryIndex.reindex();
|
await recoveryIndex.reindex();
|
||||||
}
|
}
|
||||||
@ -147,9 +152,7 @@ ipcMain.on("seshat", async function (_ev: IpcMainEvent, payload): Promise<void>
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "deleteEventIndex": {
|
case "deleteEventIndex": {
|
||||||
try {
|
await deleteContents(eventStorePath);
|
||||||
await deleteContents(eventStorePath);
|
|
||||||
} catch {}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user