diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-11-05 12:33:53 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-11-05 12:34:09 +0000 |
commit | fec183631eee46ce3f00605142c6dfb122797e27 (patch) | |
tree | dc25704d936ebe5f679e9579f1fef5a90e194894 | |
parent | f54e49512910f2958141a51cb685009ed39b2906 (diff) | |
download | mogilefs-client-fec183631eee46ce3f00605142c6dfb122797e27.tar.gz |
-rw-r--r-- | lib/mogilefs/http_file.rb | 5 | ||||
-rw-r--r-- | lib/mogilefs/mogilefs.rb | 1 | ||||
-rw-r--r-- | test/test_mogilefs.rb | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/lib/mogilefs/http_file.rb b/lib/mogilefs/http_file.rb index 81f6ad4..c40580b 100644 --- a/lib/mogilefs/http_file.rb +++ b/lib/mogilefs/http_file.rb @@ -65,9 +65,11 @@ class MogileFS::HTTPFile < StringIO # returns file size if the socket finished writing def upload(devid, uri) # :nodoc: sock = MogileFS::Socket.tcp(uri.host, uri.port) + file_size = length if @streaming_io - request_put(sock, uri, @streaming_io.length) do |wr| + file_size = @streaming_io.length + request_put(sock, uri, file_size) do |wr| @streaming_io.call(Proc.new do |data_to_write| wr.write(data_to_write) end) @@ -80,7 +82,6 @@ class MogileFS::HTTPFile < StringIO end end else - file_size = length sock.write("PUT #{uri.request_uri} HTTP/1.0\r\n" \ "Content-Length: #{file_size}\r\n\r\n#{string}") end diff --git a/lib/mogilefs/mogilefs.rb b/lib/mogilefs/mogilefs.rb index 9e2df0b..16064a2 100644 --- a/lib/mogilefs/mogilefs.rb +++ b/lib/mogilefs/mogilefs.rb @@ -142,7 +142,6 @@ class MogileFS::MogileFS < MogileFS::Client size = File.size(file) if size > 0x10000 # Bigass file, handle differently mfp.big_io = file - size else MogileFS::X.copy_stream(file, mfp) end diff --git a/test/test_mogilefs.rb b/test/test_mogilefs.rb index cd413c7..bc17223 100644 --- a/test/test_mogilefs.rb +++ b/test/test_mogilefs.rb @@ -523,7 +523,7 @@ class TestMogileFS__MogileFS < TestMogileFS orig_size = to_put.size nr = @client.store_file('new_key', 'test', to_put.path) - assert nr + assert nr, nr.inspect assert_equal orig_size, nr assert_equal orig_size, to_put.size readed.sysseek(0) |