Crash dump files location fix on Windows

This commit is contained in:
Salah Benmoussati 2021-12-22 11:36:33 +01:00 committed by Salah Benmoussati
parent 26ee577386
commit c6fa5f6040

View File

@ -4,7 +4,7 @@ import * as fs from 'fs';
import * as path from 'path';
import { ILogs } from '../common/api-interface';
import { isLinux, isMac } from '../common/env';
import { isLinux, isMac, isWindowsOS } from '../common/env';
import { i18n } from '../common/i18n';
import { logger } from '../common/logger';
@ -179,10 +179,8 @@ export const exportLogs = (): void => {
*/
export const exportCrashDumps = (): void => {
const FILE_EXTENSIONS = isMac ? ['.dmp'] : ['.dmp', '.txt'];
const crashesDirectory = app.getPath('crashDumps');
const source = isMac ? crashesDirectory + '/completed' : crashesDirectory;
const source = getCrashesDirectory();
const focusedWindow = BrowserWindow.getFocusedWindow();
if (
!fs.existsSync(source) ||
(fs.readdirSync(source).length === 0 &&
@ -219,3 +217,14 @@ export const exportCrashDumps = (): void => {
}
});
};
const getCrashesDirectory = (): string => {
const crashesDirectory = app.getPath('crashDumps');
let source = crashesDirectory;
if (isMac) {
source += '/completed';
} else if (isWindowsOS) {
source += '\\reports';
}
return source;
};