File node - don't hose status web socket on multiple file writes

and add close behaviour to info
This commit is contained in:
Dave Conway-Jones
2017-06-29 11:40:47 +01:00
parent dfc4e99560
commit adca1d7855
2 changed files with 10 additions and 1 deletions

View File

@@ -32,7 +32,13 @@ module.exports = function(RED) {
this.on("input",function(msg) {
var filename = node.filename || msg.filename || "";
if (!node.filename) { node.status({fill:"grey",shape:"dot",text:filename}); }
if ((!node.filename) && (!node.tout)) {
node.tout = setTimeout(function() {
node.status({fill:"grey",shape:"dot",text:filename});
clearTimeout(node.tout);
node.tout = null;
},333);
}
if (filename === "") { node.warn(RED._("file.errors.nofilename")); }
else if (node.overwriteFile === "delete") {
fs.unlink(filename, function (err) {
@@ -80,6 +86,7 @@ module.exports = function(RED) {
});
this.on('close', function() {
if (node.wstream) { node.wstream.end(); }
if (node.tout) { clearTimeout(node.tout); }
node.status({});
});
}