diff --git a/src/unix/fs.c b/src/unix/fs.c index b37cfbbc7a0..e34a8b09622 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -1076,16 +1076,12 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) { bytes_to_send = src_statsbuf.st_size; in_offset = 0; while (bytes_to_send != 0) { - err = uv_fs_sendfile(NULL, - &fs_req, - dstfd, - srcfd, - in_offset, - bytes_to_send, - NULL); + uv_fs_sendfile(NULL, &fs_req, dstfd, srcfd, in_offset, bytes_to_send, NULL); uv_fs_req_cleanup(&fs_req); - if (err < 0) + if (fs_req.result < 0) { + err = fs_req.result; break; + } bytes_to_send -= fs_req.result; in_offset += fs_req.result; }