From b960d46e4a56257d53a0698a11110930d832396e Mon Sep 17 00:00:00 2001 From: Ilya Vilensky Date: Wed, 25 Mar 2020 17:36:11 +0200 Subject: [PATCH] Fixed recovering from old data removal error (#457) --- desktop/nodeManager.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/desktop/nodeManager.js b/desktop/nodeManager.js index a9fe52ee7..122cef3b3 100644 --- a/desktop/nodeManager.js +++ b/desktop/nodeManager.js @@ -48,9 +48,6 @@ class NodeManager { await FileSystemManager._writeFile({ filePath: `${tomlFileLocation}`, fileContent: tomlData }); if (prevGenesisTime !== fetchedGenesisTime) { - StoreService.set({ key: 'genesisTime', value: fetchedGenesisTime }); - StoreService.remove({ key: 'miningParams' }); - await FileSystemManager.cleanWalletFile(); const command = os.type() === 'Windows_NT' ? `(if exist ${nodeDataFilesPath} rd /s /q ${nodeDataFilesPath}) && (if exist ${logFilePath} del ${logFilePath})` @@ -58,12 +55,16 @@ class NodeManager { exec(command, (err) => { if (!err) { const nodePathWithParams = `"${nodePath}" --grpc-server --json-server --tcp-port ${port} --config "${tomlFileLocation}" -d "${nodeDataFilesPath}" > "${logFilePath}"`; - exec(nodePathWithParams, (error) => { + exec(nodePathWithParams, async (error) => { if (error) { (process.env.NODE_ENV !== 'production' || process.env.DEBUG_PROD === 'true') && dialog.showErrorBox('Smesher Start Error', `${error}`); console.error(error); // eslint-disable-line no-console + } else { + StoreService.set({ key: 'genesisTime', value: fetchedGenesisTime }); + StoreService.remove({ key: 'miningParams' }); + await FileSystemManager.cleanWalletFile(); + console.log('node started with provided params'); // eslint-disable-line no-console } - console.log('node started with provided params'); // eslint-disable-line no-console }); } else { dialog.showErrorBox('Old data files removal failed', `${err}`);