From f7434b5ec8ab8e1790d4f625d78d1e41dfcb552a Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 15 Jun 2018 13:25:05 +0100 Subject: [PATCH] Add output to File Out node and update icons --- editor/icons/file-in.png | Bin 0 -> 542 bytes editor/icons/file-out.png | Bin 0 -> 503 bytes nodes/core/storage/50-file.html | 7 ++--- nodes/core/storage/50-file.js | 47 ++++++++++++++++++++++---------- 4 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 editor/icons/file-in.png create mode 100644 editor/icons/file-out.png diff --git a/editor/icons/file-in.png b/editor/icons/file-in.png new file mode 100644 index 0000000000000000000000000000000000000000..d3e5cd7fee68ea5d99fc0e644f4e5871f5badcd4 GIT binary patch literal 542 zcmV+(0^$9MP)ugK~!jg?Uy}H!$1&5zkxs>i8G|(8mW+IIRpraW6&bOC1@!q zLPM7;1c@sUQ4{efY|DvbC$_Ucme|*3yz{c2omoqXL?V$$IES88*0>+KAl@V$3i^?B zEa+a+gP>bUPlE0wJqo&!^elL|WB|d#Bm)WdmkcP_PcpDzcgYBXjgq6z+uIT|GZ*U| zxmd&}|4XoCtv$7=;ey&aX$p44iKJIa(=C~rx(zO9W(JHU%_U8$zg6R-)S#IyC0$Bd z?u(6fNX+a*(v_suuDGbD*v#G}-F1Gj#}sHyL%!lTcWqqhNxREd^k!t34-3W6XAg1{VY5&NoT=+$rS|qBv%q_mt0Y>O>$+yddWW!%t{W`?JYz^#G=l|qKGH|O7LOn zhSu3l&G3ojoMdjk0G@%d;!jnPn%iPQ5fN400&l?1UN0?JHG?8@04{-pmDCc|ArX;x z;0pM(*ZIk&bXezz$SZKOf?xYFBO><{B)gl^u4R5ZsOn4a@$&02bGp#_YO+jrcZxGb zU6XC{s&h?t&kQDN?X73`w7fZpW15ZEKC3L-!-r>6m$N#E=j5u*4g!uX}dQ4D(v2 0) { if (node.overwriteFile === "true") { - node.wstream = fs.createWriteStream(filename, { encoding:'binary', flags:'w', autoClose:true }); - node.wstream.on("error", function(err) { - node.error(RED._("file.errors.writefail",{error:err.toString()}),msg); - }); - node.wstream.end(node.data.shift()); + (function(packet) { + node.wstream = fs.createWriteStream(filename, { encoding:'binary', flags:'w', autoClose:true }); + node.wstream.on("error", function(err) { + node.error(RED._("file.errors.writefail",{error:err.toString()}),msg); + }); + node.wstream.on("open", function() { + node.wstream.end(packet.data, function() { + node.send(packet.msg); + }); + }) + })(node.data.shift()); } else { // Append mode @@ -115,10 +127,17 @@ module.exports = function(RED) { } if (node.filename) { // Static filename - write and reuse the stream next time - node.wstream.write(node.data.shift()); + var packet = node.data.shift() + node.wstream.write(packet.data, function() { + node.send(packet.msg); + }); + } else { // Dynamic filename - write and close the stream - node.wstream.end(node.data.shift()); + var packet = node.data.shift() + node.wstream.end(packet.data, function() { + node.send(packet.msg); + }); delete node.wstream; delete node.wstreamIno; }