Skip to content

Commit

Permalink
zipped_stream in package.rb now always used the StringIO hack on all
Browse files Browse the repository at this point in the history
platforms at all times. (Grrrr ZLib!)


git-svn-id: http://rubygems.rubyforge.org/svn/trunk@1227 3d4018f9-ac1a-0410-99e9-8a154d859a19
  • Loading branch information
jimweirich committed May 10, 2007
1 parent 5cc566f commit 07d14c5
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions lib/rubygems/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -607,21 +607,20 @@ def each(&block)

# Return an IO stream for the zipped entry.
#
# If zlib is earlier than 1.2.1, then read the entry into memory
# and create a string IO object from it. This avoids a "buffer
# error" problem on windows when using an earlier version of zlib.
# This problem has not been observed in versions of zlib 1.2.1 or
# later. (Update: Kornelius Kalnbach has reported seeing it in
# zlib 1.2.1, so the condition now provides the workaround for
# 1.2.1 as well)
# NOTE: Originally this method used two approaches, Return a GZipReader
# directly, or read the GZipReader into a string and return a StringIO on
# the string. The string IO approach was used for versions of ZLib before
# 1.2.1 to avoid buffer errors on windows machines. Then we found that
# errors happened with 1.2.1 as well, so we changed the condition. Then
# we discovered errors occurred with versions as late as 1.2.3. At this
# point (after some benchmarking to show we weren't seriously crippling
# the unpacking speed) we threw our hands in the air and declared that
# this method would use the String IO approach on all platforms at all
# times. And that's the way it is.
def zipped_stream(entry)
if Zlib::ZLIB_VERSION <= '1.2.1'
zis = Zlib::GzipReader.new entry
dis = zis.read
is = StringIO.new(dis)
else
is = Zlib::GzipReader.new entry
end
zis = Zlib::GzipReader.new entry
dis = zis.read
is = StringIO.new(dis)
ensure
zis.finish if zis
end
Expand Down

0 comments on commit 07d14c5

Please sign in to comment.