Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Commit

Permalink
fix maxBuffer exceeded error
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Zhang committed Jun 13, 2018
1 parent e271515 commit c03fdde
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ app.on('ready', () => {
// aria2
function startAria2 () {
const AppData = require('./appdata').default
const exec = require('child_process').exec
const spawn = require('child_process').spawn
const join = require('path').join
const platform = require('os').platform()
const homedir = require('os').homedir()
Expand All @@ -160,16 +160,13 @@ function startAria2 () {
}, AppData.readData() || {})
if (!options.hasOwnProperty('dir')) options['dir'] = join(homedir, 'Downloads')

let command = '"' + aria2c + '" --conf-path="' + conf + '"'
for (let key in options) command += ' --' + key + '="' + options[key] + '"'
return exec(command, (error, stdout, stderr) => {
if (error) {
console.error(error.message)
const message = 'conflicts with an existing aria2 instance. Please stop the instance and reopen the app.'
dialog.showErrorBox('Warning', message)
app.quit()
}
if (stderr) console.warn(stderr)
if (stdout) console.log(stdout)
let command = '"' + aria2c + '"'
let args = ['--conf-path="' + conf + '"']
for (let key in options) args.push('--' + key + '="' + options[key] + '"')
let subprocess = spawn(command, args, { shell: true })
subprocess.on('exit', (code, signal) => {
if (code === 1) dialog.showErrorBox('Warning', 'conflicts with an existing aria2 instance. Please stop the instance and reopen the app.')
app.quit()
})
return subprocess
}

0 comments on commit c03fdde

Please sign in to comment.