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

Function writeCb

lib/protocol/SFTP.js:2326–2358  ·  view source on GitHub ↗
(err)

Source from the content-addressed store, hash-verified

2324 dst.write(dstHandle, readbuf, datapos, nb, dstpos, writeCb);
2325
2326 function writeCb(err) {
2327 if (err)
2328 return onerror(err);
2329
2330 total += nb;
2331 onstep && onstep(total, nb, fsize);
2332
2333 if (nb < origChunkLen)
2334 return singleRead(datapos, dstpos + nb, origChunkLen - nb);
2335
2336 if (total === fsize) {
2337 dst.close(dstHandle, (err) => {
2338 dstHandle = undefined;
2339 if (err)
2340 return onerror(err);
2341 src.close(srcHandle, (err) => {
2342 srcHandle = undefined;
2343 if (err)
2344 return onerror(err);
2345 cb();
2346 });
2347 });
2348 return;
2349 }
2350
2351 if (pdst >= fsize)
2352 return;
2353
2354 const chunk =
2355 (pdst + chunkSize > fsize ? fsize - pdst : chunkSize);
2356 singleRead(datapos, pdst, chunk);
2357 pdst += chunk;
2358 }
2359 }
2360
2361 function makeCb(psrc, pdst, chunk) {

Callers

nothing calls this directly

Calls 3

onerrorFunction · 0.85
singleReadFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…