Merge pull request #396 from hindessm/delete-should-not-require-defined-payload

Fix logic so defined msg.payload is not prereq for delete.
This commit is contained in:
Nick O'Leary 2014-09-09 20:47:54 +01:00
commit 50f1a17920
1 changed files with 21 additions and 24 deletions

View File

@ -28,14 +28,12 @@ module.exports = function(RED) {
var filename = msg.filename || this.filename;
if (filename === "") {
node.warn('No filename specified');
} else if (typeof msg.payload != "undefined") {
if (msg.hasOwnProperty('delete')) {
} else if (msg.hasOwnProperty('delete')) {
fs.unlink(filename, function (err) {
if (err) { node.warn('Failed to delete file : '+err); }
//console.log('Deleted file",filename);
});
}
else {
} else if (typeof msg.payload != "undefined") {
var data = msg.payload;
if (typeof data == "object") {
if (!Buffer.isBuffer(data)) {
@ -57,7 +55,6 @@ module.exports = function(RED) {
});
}
}
}
});
}
RED.nodes.registerType("file",FileNode);