diff --git a/src/seshat.ts b/src/seshat.ts index edf2636..778c697 100644 --- a/src/seshat.ts +++ b/src/seshat.ts @@ -60,9 +60,17 @@ async function getOrCreatePassphrase(key: string): Promise { } const deleteContents = async (p: string): Promise => { - for (const entry of await afs.readdir(p)) { - const curPath = path.join(p, entry); - await afs.unlink(curPath); + try { + for (const entry of await afs.readdir(p)) { + 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 // anyways so reindexing it is a waste of time. if (userVersion === 0) { await recoveryIndex.shutdown(); - - try { - await deleteContents(eventStorePath); - } catch {} + await deleteContents(eventStorePath); } else { await recoveryIndex.reindex(); } @@ -147,9 +152,7 @@ ipcMain.on("seshat", async function (_ev: IpcMainEvent, payload): Promise break; case "deleteEventIndex": { - try { - await deleteContents(eventStorePath); - } catch {} + await deleteContents(eventStorePath); break; }