signal-desktop/ts/shims/deleteAllData.ts

37 lines
892 B
TypeScript
Raw Normal View History

2021-08-24 20:57:34 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as log from '../logging/log';
import { deleteAllLogs } from '../util/deleteAllLogs';
import * as Errors from '../types/errors';
2021-08-24 20:57:34 +00:00
export async function deleteAllData(): Promise<void> {
try {
await deleteAllLogs();
2021-08-24 20:57:34 +00:00
log.info('deleteAllData: deleted all logs');
2021-08-24 20:57:34 +00:00
await window.Signal.Data.removeAll();
log.info('deleteAllData: emptied database');
2021-08-24 20:57:34 +00:00
await window.Signal.Data.close();
log.info('deleteAllData: closed database');
2021-08-24 20:57:34 +00:00
await window.Signal.Data.removeDB();
log.info('deleteAllData: removed database');
2021-08-24 20:57:34 +00:00
await window.Signal.Data.removeOtherData();
log.info('deleteAllData: removed all other data');
2021-08-24 20:57:34 +00:00
} catch (error) {
log.error(
2021-08-24 20:57:34 +00:00
'Something went wrong deleting all data:',
Errors.toLogFormat(error)
2021-08-24 20:57:34 +00:00
);
}
2023-01-13 00:24:59 +00:00
window.IPC.restart();
2021-08-24 20:57:34 +00:00
}