fix: make sure we only try to delete data once

pull/3065/head
Audric Ackermann 2 months ago
parent 425e63a4ce
commit cfcbc013e5

@ -18,11 +18,22 @@ import { SessionRadioGroup } from '../basic/SessionRadioGroup';
const deleteDbLocally = async () => {
window?.log?.info('last message sent successfully. Deleting everything');
window.persistStore?.purge();
window?.log?.info('store purged');
await deleteAllLogs();
window?.log?.info('ladelete logs');
await Data.removeAll();
window?.log?.info('data removeall');
await Data.close();
window?.log?.info('db closed');
await Data.removeDB();
window?.log?.info('db removed');
await Data.removeOtherData();
window?.log?.info('otherdata removed');
window.localStorage.setItem('restart-reason', 'delete-account');
};

@ -790,8 +790,20 @@ async function removeDB() {
try {
console.error('Remove DB: removing.', userDir);
userConfig.remove();
ephemeralConfig.remove();
try {
userConfig.remove();
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
try {
ephemeralConfig.remove();
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
} catch (e) {
console.error('Remove DB: Failed to remove configs.', e);
}

@ -1,7 +1,7 @@
import { app, ipcMain } from 'electron';
import { sqlNode } from './sql'; // checked - only node
import { userConfig } from './config/user_config'; // checked - only node
import { ephemeralConfig } from './config/ephemeral_config'; // checked - only node
import { userConfig } from './config/user_config'; // checked - only node
import { sqlNode } from './sql'; // checked - only node
let initialized = false;
@ -31,8 +31,20 @@ export function initializeSqlChannel() {
ipcMain.on(ERASE_SQL_KEY, event => {
try {
userConfig.remove();
ephemeralConfig.remove();
try {
userConfig.remove();
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
try {
ephemeralConfig.remove();
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
event.sender.send(`${ERASE_SQL_KEY}-done`);
} catch (error) {
const errorForDisplay = error && error.stack ? error.stack : error;

@ -1,8 +1,8 @@
import path from 'path';
import { app, BrowserWindow, Menu, Tray } from 'electron';
import { LocaleMessagesType } from './locale';
import { getAppRootPath } from './getRootPath';
import { LocaleMessagesType } from './locale';
let trayContextMenu = null;
let tray: Tray | null = null;

Loading…
Cancel
Save