Pass crashes directory instead of product name and temp dir
This commit is contained in:
parent
16e3991ffa
commit
d39182b41a
10 changed files with 58 additions and 77 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
const {spawn} = require('child_process')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const electron = require('electron')
|
||||
const {app} = process.type === 'browser' ? electron : electron.remote
|
||||
const binding = process.atomBinding('crash_reporter')
|
||||
|
@ -11,13 +12,9 @@ class CrashReporter {
|
|||
if (options == null) {
|
||||
options = {}
|
||||
}
|
||||
this.productName = options.productName
|
||||
this.productName = options.productName != null ? options.productName : app.getName()
|
||||
let {autoSubmit, companyName, extra, ignoreSystemCrashHandler, submitURL} = options
|
||||
|
||||
this.tempDirectory = getTempPath()
|
||||
if (this.productName == null) {
|
||||
this.productName = app.getName()
|
||||
}
|
||||
if (autoSubmit == null) {
|
||||
autoSubmit = true
|
||||
}
|
||||
|
@ -28,7 +25,7 @@ class CrashReporter {
|
|||
extra = {}
|
||||
}
|
||||
if (extra._productName == null) {
|
||||
extra._productName = this.productName
|
||||
extra._productName = this.getProductName()
|
||||
}
|
||||
if (extra._companyName == null) {
|
||||
extra._companyName = companyName
|
||||
|
@ -46,8 +43,8 @@ class CrashReporter {
|
|||
if (process.platform === 'win32') {
|
||||
const args = [
|
||||
'--reporter-url=' + submitURL,
|
||||
'--application-name=' + this.productName,
|
||||
'--crashes-directory=' + binding._getCrashesDirectory(this.productName, this.tempDirectory),
|
||||
'--application-name=' + this.getProductName(),
|
||||
'--crashes-directory=' + this.getCrashesDirectory(),
|
||||
'--v=1'
|
||||
]
|
||||
const env = {
|
||||
|
@ -59,7 +56,7 @@ class CrashReporter {
|
|||
})
|
||||
}
|
||||
|
||||
binding.start(this.productName, companyName, submitURL, this.tempDirectory, autoSubmit, ignoreSystemCrashHandler, extra)
|
||||
binding.start(this.getProductName(), companyName, submitURL, this.getCrashesDirectory(), autoSubmit, ignoreSystemCrashHandler, extra)
|
||||
}
|
||||
|
||||
getLastCrashReport () {
|
||||
|
@ -72,18 +69,31 @@ class CrashReporter {
|
|||
}
|
||||
|
||||
getUploadedReports () {
|
||||
const productName = this.productName != null ? this.productName : app.getName()
|
||||
const tempDirectory = this.tempDirectory != null ? this.tempDirectory : getTempPath()
|
||||
return binding._getUploadedReports(productName, tempDirectory)
|
||||
return binding._getUploadedReports(this.getCrashesDirectory())
|
||||
}
|
||||
}
|
||||
|
||||
const getTempPath = () => {
|
||||
try {
|
||||
return app.getPath('temp')
|
||||
} catch (error) {
|
||||
// app.getPath may throw so fallback to OS temp directory
|
||||
return os.tmpdir()
|
||||
getCrashesDirectory () {
|
||||
const crashesDir = this.getProductName() + ' Crashes'
|
||||
return path.join(this.getTempDirectory(), crashesDir)
|
||||
}
|
||||
|
||||
getProductName () {
|
||||
if (this.productName == null) {
|
||||
this.productName = app.getName()
|
||||
}
|
||||
return this.productName
|
||||
}
|
||||
|
||||
getTempDirectory () {
|
||||
if (this.tempDirectory == null) {
|
||||
try {
|
||||
this.tempDirectory = app.getPath('temp')
|
||||
} catch (error) {
|
||||
// app.getPath may throw so fallback to OS temp directory
|
||||
this.tempDirectory = os.tmpdir()
|
||||
}
|
||||
}
|
||||
return this.tempDirectory
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue