()
| 293 | // Discard the partial file once its handle is closed (Windows refuses |
| 294 | // to unlink an open file), then report the failure. |
| 295 | const discard = () => { |
| 296 | try { fs.unlinkSync(dest); } catch (_) { /* nothing was written */ } |
| 297 | finish(err); |
| 298 | }; |
| 299 | if (file.closed) discard(); |
| 300 | else file.once('close', discard); |
| 301 | }); |