aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/io.c b/io.c
index f1c3cd45d3..188c998f98 100644
--- a/io.c
+++ b/io.c
@@ -6579,7 +6579,7 @@ copy_stream_fallback_body(VALUE arg)
while (1) {
long numwrote;
- long l = buflen < rest ? buflen : rest;
+ long l;
if (stp->copy_length == (off_t)-1) {
l = buflen;
}
@@ -6604,9 +6604,18 @@ copy_stream_fallback_body(VALUE arg)
if (off != (off_t)-1)
off += ss;
}
- n = rb_io_write(stp->dst, buf);
- numwrote = NUM2LONG(n);
- stp->total += numwrote;
+ if (stp->dst_fd == -1) {
+ n = rb_io_write(stp->dst, buf);
+ numwrote = NUM2LONG(n);
+ stp->total += numwrote;
+ }
+ else {
+ ssize_t ss;
+ numwrote = RSTRING_LEN(buf);
+ ss = copy_stream_write(stp, RSTRING_PTR(buf), numwrote);
+ if (ss == -1)
+ return Qnil;
+ }
rest -= numwrote;
}