2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2018-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-09-21 00:25:29 +00:00
|
|
|
import { ipcRenderer } from 'electron';
|
2018-03-08 00:16:03 +00:00
|
|
|
|
2021-09-21 00:25:29 +00:00
|
|
|
import { beforeRestart } from '../logging/set_up_renderer_logging';
|
2021-05-13 20:54:54 +00:00
|
|
|
|
2021-09-21 00:25:29 +00:00
|
|
|
export function deleteAllLogs(): Promise<void> {
|
2018-03-08 00:16:03 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
2021-05-13 20:54:54 +00:00
|
|
|
// Restart logging again when the file stream close
|
|
|
|
beforeRestart();
|
|
|
|
|
2021-09-21 00:25:29 +00:00
|
|
|
const timeout = setTimeout(() => {
|
2018-03-08 00:16:03 +00:00
|
|
|
reject(new Error('Request to delete all logs timed out'));
|
|
|
|
}, 5000);
|
|
|
|
|
2021-09-21 00:25:29 +00:00
|
|
|
ipcRenderer.once('delete-all-logs-complete', () => {
|
|
|
|
clearTimeout(timeout);
|
|
|
|
resolve();
|
|
|
|
});
|
|
|
|
|
2018-03-08 00:16:03 +00:00
|
|
|
ipcRenderer.send('delete-all-logs');
|
|
|
|
});
|
|
|
|
}
|