Permalink
Browse files

changed where the .each was called on opening a new s3 file

  • Loading branch information...
1 parent 993ec97 commit da34c2fc9ccd220ce1494b5e580d76d17d01ac23 @thedatachef thedatachef committed Mar 3, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/swineherd/filesystem/s3filesystem.rb
@@ -193,7 +193,6 @@ def initialize path, mode, fs, &blk
case mode
when "r" then
raise "#{fs.type(path)} is not a readable file - #{path}" unless fs.type(path) == "file"
- @handle = fs.s3.interface.get_object(fs.bucket(path), fs.key_path(path)).each
when "w" then
raise "Path #{path} is a directory." unless (fs.type(path) == "file") || (fs.type(path) == "unknown")
@handle = Tempfile.new('s3filestream')
@@ -208,10 +207,16 @@ def initialize path, mode, fs, &blk
# Faster than iterating
#
def read
- fs.s3.interface.get_object(fs.bucket(path), fs.key_path(path))
+ resp = fs.s3.interface.get_object(fs.bucket(path), fs.key_path(path))
+ resp
end
+ #
+ # This is a little hackety. That is, once you call (.each) on the object the full object starts
+ # downloading...
+ #
def readline
+ @handle ||= fs.s3.interface.get_object(fs.bucket(path), fs.key_path(path)).each
begin
@handle.next
rescue StopIteration, NoMethodError

0 comments on commit da34c2f

Please sign in to comment.