From 86480770888cdeda8929f227da80b193155218ab Mon Sep 17 00:00:00 2001 From: pbca26 Date: Sat, 18 Mar 2017 08:55:27 +0300 Subject: [PATCH] fixed a bug in shepherd kick api --- main.js | 31 +++++++++++++++++-------------- routes/shepherd.js | 23 ++++++++++++++--------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/main.js b/main.js index 59f43fe..8a5cea1 100644 --- a/main.js +++ b/main.js @@ -61,8 +61,11 @@ process.once('loaded', () => { } }); -guiapp.use(bodyParser.json({limit: '50mb'})); // support json encoded bodies -guiapp.use(bodyParser.urlencoded({limit: '50mb', extended: true})); // support encoded bodies +guiapp.use(bodyParser.json({ limit: '50mb' })); // support json encoded bodies +guiapp.use(bodyParser.urlencoded({ + limit: '50mb', + extended: true +})); // support encoded bodies guiapp.get('/', function (req, res) { res.send('Iguana app server'); @@ -196,7 +199,7 @@ function createLoadingWindow() { // putting them into an window_arr loadingWindow = null; createWindow('open'); - }) + }); //ca333 todo - add os detector to use correct binary - so we can use the same bundle on ALL OS platforms /*if (os.platform() === 'win32') { @@ -234,20 +237,20 @@ function createWindow (status) { }); const staticMenu = Menu.buildFromTemplate([ //if static - {role: 'copy'}, - {type: 'separator'}, - {role: 'selectall'}, + { role: 'copy' }, + { type: 'separator' }, + { role: 'selectall' }, ]) const editMenu = Menu.buildFromTemplate([ //if editable - {role: 'undo'}, - {role: 'redo'}, - {type: 'separator'}, - {role: 'cut'}, - {role: 'copy'}, - {role: 'paste'}, - {type: 'separator'}, - {role: 'selectall'}, + { role: 'undo' }, + { role: 'redo' }, + { type: 'separator' }, + { role: 'cut' }, + { role: 'copy' }, + { role: 'paste' }, + { type: 'separator' }, + { role: 'selectall' }, ]) // load our index.html (i.e. easyDEX GUI) diff --git a/routes/shepherd.js b/routes/shepherd.js index f982b09..acdcf92 100644 --- a/routes/shepherd.js +++ b/routes/shepherd.js @@ -1227,8 +1227,9 @@ shepherd.get('/kick', function(req, res, next) { var kickStartDirs = { 'soft': [ { - 'name': 'DB/[coin]/balancecrc.', - 'type': 'pattern' + 'name': 'DB/[coin]', + 'type': 'pattern', + 'match': 'balancecrc.' }, { 'name': 'DB/[coin]/utxoaddrs', @@ -1301,23 +1302,27 @@ shepherd.get('/kick', function(req, res, next) { if (_coin && _type) { for (var i = 0; i < kickStartDirs[_type].length; i++) { - console.log('deleting ' + kickStartDirs[_type][i].type + (kickStartDirs[_type][i].match ? ' ' + kickStartDirs[_type][i].match : '') + ' ' + iguanaDir + '/' + kickStartDirs[_type][i].name.replace('[coin]', _coin)); - if (kickStartDirs[_type][i].type === 'folder' || kickStartDirs[_type][i].type === 'file') { - rimraf(iguanaDir + '/' + kickStartDirs[_type][i].name.replace('[coin]', _coin), function(err) { + var currentKickItem = kickStartDirs[_type][i]; + + console.log('deleting ' + currentKickItem.type + (currentKickItem.match ? ' ' + currentKickItem.match : '') + ' ' + iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin)); + if (currentKickItem.type === 'folder' || currentKickItem.type === 'file') { + rimraf(iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin), function(err) { if (err) { throw err; } }); - } else if (kickStartDirs[_type][i].type === 'pattern') { - var dirItems = fs.readdirSync(iguanaDir + '/' + kickStartDirs[_type][i].name.replace('[coin]', _coin)); + } else if (currentKickItem.type === 'pattern') { + var dirItems = fs.readdirSync(iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin)); + if (dirItems && dirItems.length) { for (var j = 0; j < dirItems.length; j++) { - if (dirItems[j].indexOf(kickStartDirs[_type][i].match) > -1) { - rimraf(iguanaDir + '/' + kickStartDirs[_type][i].name.replace('[coin]', _coin) + '/' + dirItems[j], function(err) { + if (dirItems[j].indexOf(currentKickItem.match) > -1) { + rimraf(iguanaDir + '/' + currentKickItem.name.replace('[coin]', _coin) + '/' + dirItems[j], function(err) { if (err) { throw err; } }); + console.log('deleting ' + dirItems[j]); } }