Browse Source

Merge pull request #1342 from gre/fixes/1337

Fixes #1337
master
Meriadec Pillet 7 years ago
committed by GitHub
parent
commit
e4d579fa54
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/components/SettingsPage/sections/Help.js
  2. 17
      src/helpers/log.js
  3. 12
      src/helpers/resolveLogsDirectory.js
  4. 2
      src/logger/logger.js
  5. 3
      src/main/bridge.js

2
src/components/SettingsPage/sections/Help.js

@ -5,7 +5,7 @@ import { translate } from 'react-i18next'
import type { T } from 'types/common'
import TrackPage from 'analytics/TrackPage'
import IconHelp from 'icons/Help'
import resolveLogsDirectory from 'helpers/resolveLogsDirectory'
import { resolveLogsDirectory } from 'helpers/log'
import { urls } from 'config/urls'
import ExportLogsBtn from 'components/ExportLogsBtn'

17
src/helpers/log.js

@ -0,0 +1,17 @@
// @flow
import path from 'path'
import rimraf from 'rimraf'
import resolveUserDataDirectory from './resolveUserDataDirectory'
export const resolveLogsDirectory = () => {
const { LEDGER_LOGS_DIRECTORY } = process.env
if (LEDGER_LOGS_DIRECTORY) return LEDGER_LOGS_DIRECTORY
const electron = require('electron')
return path.resolve((electron.app || electron.remote.app).getPath('userData'), 'logs')
}
export const cleanUpBeforeClosingSync = () => {
rimraf.sync(resolveLogsDirectory(), { disableGlob: true })
rimraf.sync(path.resolve(resolveUserDataDirectory(), 'sqlite/*.log'))
}

12
src/helpers/resolveLogsDirectory.js

@ -1,12 +0,0 @@
// @flow
import path from 'path'
const resolveLogsDirectory = () => {
const { LEDGER_LOGS_DIRECTORY } = process.env
if (LEDGER_LOGS_DIRECTORY) return LEDGER_LOGS_DIRECTORY
const electron = require('electron')
return path.resolve((electron.app || electron.remote.app).getPath('userData'), 'logs')
}
export default resolveLogsDirectory

2
src/logger/logger.js

@ -2,7 +2,7 @@
import winston from 'winston'
import Transport from 'winston-transport'
import resolveLogsDirectory from 'helpers/resolveLogsDirectory'
import { resolveLogsDirectory } from 'helpers/log'
import anonymizer from 'helpers/anonymizer'
import pname from 'helpers/pname'

3
src/main/bridge.js

@ -9,7 +9,7 @@ import path from 'path'
import logger from 'logger'
import sentry, { captureException } from 'sentry/node'
import user from 'helpers/user'
import resolveLogsDirectory from 'helpers/resolveLogsDirectory'
import { resolveLogsDirectory, cleanUpBeforeClosingSync } from 'helpers/log'
import { deserializeError } from 'helpers/errors'
import setupAutoUpdater, { quitAndInstall } from './autoUpdate'
@ -69,6 +69,7 @@ const bootInternalProcess = () => {
process.on('exit', () => {
killInternalProcess()
cleanUpBeforeClosingSync()
})
ipcMain.on('clean-processes', () => {

Loading…
Cancel
Save