Merge pull request #1586 from node-red-hitachi/fix-file-in-parts

fix behavior of "a msg per line" mode of FILE IN node with empty line
This commit is contained in:
Nick O'Leary
2018-01-29 11:14:07 +00:00
committed by GitHub
2 changed files with 66 additions and 16 deletions

View File

@@ -189,14 +189,9 @@ module.exports = function(RED) {
parts:{index:count, ch:ch, type:type, id:msg._msgid}
}
count += 1;
if ((chunk.length < hwm) && (bits[i+1].length === 0)) {
m.parts.count = count;
}
node.send(m);
}
spare = bits[i];
if (chunk.length !== hwm) { getout = false; }
//console.log("LEFT",bits[i].length,bits[i]);
}
if (node.format === "stream") {
var m = {
@@ -233,6 +228,18 @@ module.exports = function(RED) {
else { msg.payload = lines; }
node.send(msg);
}
else if (node.format === "lines") {
var m = { payload: spare,
parts: {
index: count,
count: count+1,
ch: ch,
type: type,
id: msg._msgid
}
};
node.send(m);
}
else if (getout) { // last chunk same size as high water mark - have to send empty extra packet.
var m = { parts:{index:count, count:count, ch:ch, type:type, id:msg._msgid} };
node.send(m);