possible server fixes

pull/1/head
ansuz 5 years ago
parent bc034d95a3
commit e1a0daac9c

@ -101,6 +101,9 @@ var getMetadataAtPath = function (Env, path, _cb) {
if (i++ > 0) {
console.log("aborting");
abort();
try { stream.close(); } catch (err) {
console.log("could not close stream");
}
return void cb();
}
var metadata;
@ -890,7 +893,7 @@ var trimChannel = function (env, channelName, hash, _cb) {
var retain = false;
var handler = function (msgObj, readMore, abort) {
if (ABORT) { return void abort(); }
if (ABORT) { return void abort(); } // XXX
// the first message might be metadata... ignore it if so
if (i++ === 0 && msgObj.buff.indexOf('{') === 0) {
return readMore();

@ -67,7 +67,15 @@ Stream.readFileBin = (stream, msgHandler, cb) => {
mkBufferSplit(),
mkOffsetCounter(),
Pull.asyncMap((data, moreCb) => {
msgHandler(data, moreCb, () => { keepReading = false; moreCb(); });
msgHandler(data, moreCb, () => {
try {
stream.close();
} catch (err) {
console.error("READ_FILE_BIN_ERR", err);
}
keepReading = false;
moreCb();
});
}),
Pull.drain(() => (keepReading), (err) => {
cb((keepReading) ? err : undefined);

Loading…
Cancel
Save