MCPcopy Create free account
hub / github.com/mscdex/ssh2 / afterRead

Method afterRead

lib/protocol/SFTP.js:559–587  ·  view source on GitHub ↗
(er, nbytes)

Source from the content-addressed store, hash-verified

557 };
558
559 const afterRead = (er, nbytes) => {
560 let eof;
561 if (er) {
562 eof = (er.code === STATUS_CODE.EOF);
563 if (!eof) {
564 return this.close(handle, () => {
565 return callback && callback(er);
566 });
567 }
568 } else {
569 eof = false;
570 }
571
572 if (eof || (size === 0 && nbytes === 0))
573 return close();
574
575 bytesRead += nbytes;
576 pos += nbytes;
577 if (size !== 0) {
578 if (pos === size)
579 close();
580 else
581 read();
582 } else {
583 // Unknown size, just read until we don't get bytes.
584 buffers.push(bufferSlice(buffer, 0, nbytes));
585 read();
586 }
587 };
588 afterRead._wantEOFError = true;
589
590 const close = () => {

Callers

nothing calls this directly

Calls 4

closeMethod · 0.95
callbackFunction · 0.85
bufferSliceFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected