diff options
-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 |