mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
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:
@@ -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);
|
||||
|
Reference in New Issue
Block a user