diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-11-01 23:38:31 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-11-01 23:38:31 +0000 |
commit | ec29cbf28b2fa3a0155462f8ee927265f9fc3d94 (patch) | |
tree | 6a0e00fabae8f754245c46848b22e821381a3ba5 | |
parent | 60a29ca15a1d90cb7ef011719111e3d6d5691614 (diff) | |
download | mogilefs-client-ec29cbf28b2fa3a0155462f8ee927265f9fc3d94.tar.gz |
-rw-r--r-- | lib/mogilefs/httpfile.rb | 2 | ||||
-rw-r--r-- | lib/mogilefs/util.rb | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/mogilefs/httpfile.rb b/lib/mogilefs/httpfile.rb index a1cd8d4..560dc23 100644 --- a/lib/mogilefs/httpfile.rb +++ b/lib/mogilefs/httpfile.rb @@ -101,7 +101,7 @@ class MogileFS::HTTPFile < StringIO file_size = fp.stat.size sock.write("PUT #{uri.request_uri} HTTP/1.0\r\n" \ "Content-Length: #{file_size}\r\n\r\n") - sysrwloop(fp, sock) + copy_stream(fp, sock) end else sock.write("PUT #{uri.request_uri} HTTP/1.0\r\n" \ diff --git a/lib/mogilefs/util.rb b/lib/mogilefs/util.rb index bca502a..596e038 100644 --- a/lib/mogilefs/util.rb +++ b/lib/mogilefs/util.rb @@ -6,6 +6,17 @@ module MogileFS::Util CHUNK_SIZE = 65536 + # TODO: cleanup + if IO.respond_to?(:copy_stream) + def copy_stream(src, dst) + IO.copy_stream(src, dst) + end + else + def copy_stream(src, dst) + sysrwloop(src, dst) + end + end + # for copying large files while avoiding GC thrashing as much as possible # writes the contents of io_rd into io_wr, running through filter if # it is a Proc object. The filter proc must respond to a string |