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

Method tryStat

lib/protocol/SFTP.js:610–635  ·  view source on GitHub ↗
(er, st)

Source from the content-addressed store, hash-verified

608 handle = handle_;
609
610 const tryStat = (er, st) => {
611 if (er) {
612 // Try stat() for sftp servers that may not support fstat() for
613 // whatever reason
614 this.stat(path, (er_, st_) => {
615 if (er_) {
616 return this.close(handle, () => {
617 callback && callback(er);
618 });
619 }
620 tryStat(null, st_);
621 });
622 return;
623 }
624
625 size = st.size || 0;
626 if (size === 0) {
627 // The kernel lies about many files.
628 // Go ahead and try to read some bytes.
629 buffers = [];
630 return read();
631 }
632
633 buffer = Buffer.allocUnsafe(size);
634 read();
635 };
636 this.fstat(handle, tryStat);
637 });
638 }

Callers

nothing calls this directly

Calls 5

statMethod · 0.95
closeMethod · 0.95
callbackFunction · 0.85
tryStatFunction · 0.85
writeAllFunction · 0.85

Tested by

no test coverage detected