diff --git a/nodes/core/storage/50-file.html b/nodes/core/storage/50-file.html index 8cb6df71d..5811d035a 100644 --- a/nodes/core/storage/50-file.html +++ b/nodes/core/storage/50-file.html @@ -40,6 +40,8 @@

Details

Each message payload will be added to the end of the file, optionally appending a newline (\n) character between each one.

+

If msg.filename is used the file will be closed after every write. + For best performance use a fixed filename.

It can be configured to overwrite the entire file rather than append. For example, when writing binary data to a file, such as an image, this option should be used and the option to append a newline should be disabled.

diff --git a/nodes/core/storage/50-file.js b/nodes/core/storage/50-file.js index 236a9b835..34796a109 100644 --- a/nodes/core/storage/50-file.js +++ b/nodes/core/storage/50-file.js @@ -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({}); }); }