Skip to content

Commit

Permalink
Fixed recovering from old data removal error (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Vilensky authored Mar 25, 2020
1 parent b1508a3 commit b960d46
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions desktop/nodeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,23 @@ 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})`
: `rm -rf ${nodeDataFilesPath} && rm -rf ${logFilePath}`;
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}`);
Expand Down

0 comments on commit b960d46

Please sign in to comment.