1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix logic so defined msg.payload is not prereq for delete.

This commit is contained in:
Mark Hindess 2014-09-09 19:46:38 +01:00
parent 0111ab8901
commit 72dcb53d23

View File

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