Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

fix: drive log files were missing upon setup #428

Merged
merged 4 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/listr/tasks/setup/setupLocalPresetTaskFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const os = require('os');
const path = require('path');

const { PRESET_LOCAL } = require('../../../constants');
const touchFile = require('../../../util/touchFile');

/**
* @param {ConfigFile} configFile
Expand Down Expand Up @@ -139,8 +140,14 @@ function setupLocalPresetTaskFactory(
});
}

config.set('platform.drive.abci.log.prettyFile.path', path.join(os.tmpdir(), `/drive_pretty_${nodeIndex}.log`));
config.set('platform.drive.abci.log.jsonFile.path', path.join(os.tmpdir(), `/drive_json_${nodeIndex}.log`));
const drivePrettyLogFile = path.join(os.tmpdir(), `/drive_pretty_${nodeIndex}.log`);
const driveJsonLogFile = path.join(os.tmpdir(), `/drive_json_${nodeIndex}.log`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove slash


config.set('platform.drive.abci.log.prettyFile.path', drivePrettyLogFile);
config.set('platform.drive.abci.log.jsonFile.path', driveJsonLogFile);

touchFile(drivePrettyLogFile);
touchFile(driveJsonLogFile);
}
},
}
Expand Down
20 changes: 20 additions & 0 deletions src/util/touchFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const fs = require('fs');

/**
* Touch or create an empty file
*
* @param {string} filePath
*
* @returns {void}
*/
function touchFile(filePath) {
const time = new Date();

try {
fs.utimesSync(filePath, time, time);
} catch (err) {
fs.closeSync(fs.openSync(filePath, 'w'));
}
}

module.exports = touchFile;