Skip to content
Snippets Groups Projects
Commit 95e1296f authored by Markus Grigull's avatar Markus Grigull
Browse files

Fix node config file delete

parent ec5f1ae5
No related branches found
No related tags found
1 merge request!7Feature change simulator connection
...@@ -35,27 +35,27 @@ var nodeSchema = new Schema({ ...@@ -35,27 +35,27 @@ var nodeSchema = new Schema({
simulators: [{ type: Schema.Types.Mixed, default: [] }] simulators: [{ type: Schema.Types.Mixed, default: [] }]
}); });
nodeSchema.pre('save', function(next) { nodeSchema.post('save', function() {
// delete old configuration file // remove old file
if (this._name != null) { if (this._name != null) {
fs.stat('nodes/' + this._name + '.conf', function(err) { var oldFile = 'nodes/' + this._name + '.conf';
fs.stat(oldFile, function(err, stat) {
if (err) { if (err) {
logger.info('Old node configuration missing', err); logger.info('Old node configuration missing', err);
return; return;
} }
fs.unlink('nodes/' + this._name + '.conf', function(err) { if (stat.isFile()) {
if (err) { fs.unlink(oldFile, function(err) {
logger.warn('Unable to delete old node configuration', err); if (err) {
} logger.warn('Unable to delete old node configuration', err);
}); }
});
}
}); });
} }
next();
});
nodeSchema.post('save', function() {
// create configuration file // create configuration file
var port = 12000; var port = 12000;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment