| 2225 | let bufsize = chunkSize * concurrency; |
| 2226 | |
| 2227 | function onerror(err) { |
| 2228 | if (hadError) |
| 2229 | return; |
| 2230 | |
| 2231 | hadError = true; |
| 2232 | |
| 2233 | let left = 0; |
| 2234 | let cbfinal; |
| 2235 | |
| 2236 | if (srcHandle || dstHandle) { |
| 2237 | cbfinal = () => { |
| 2238 | if (--left === 0) |
| 2239 | cb(err); |
| 2240 | }; |
| 2241 | if (srcHandle && (src === fs || src.outgoing.state === 'open')) |
| 2242 | ++left; |
| 2243 | if (dstHandle && (dst === fs || dst.outgoing.state === 'open')) |
| 2244 | ++left; |
| 2245 | if (srcHandle && (src === fs || src.outgoing.state === 'open')) |
| 2246 | src.close(srcHandle, cbfinal); |
| 2247 | if (dstHandle && (dst === fs || dst.outgoing.state === 'open')) |
| 2248 | dst.close(dstHandle, cbfinal); |
| 2249 | } else { |
| 2250 | cb(err); |
| 2251 | } |
| 2252 | } |
| 2253 | |
| 2254 | src.open(srcPath, 'r', (err, sourceHandle) => { |
| 2255 | if (err) |