Flowdock
method

zipped_stream

Importance_2
Ruby latest stable (v1_9_3_392) - 0 notes - Class: TarInput
zipped_stream(entry) public

Return an IO stream for the zipped entry.

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.

Revisited. Here’s the beginning of the long story. http://osdir.com/ml/lang.ruby.gems.devel/2007-06/msg00045.html

StringIO wraping has never worked as a workaround by definition. Skipping initial 10 bytes and passing -MAX_WBITS to Zlib::Inflate luckily works as gzip reader, but it only works if the GZip header is 10 bytes long (see below) and it does not check inflated stream consistency (CRC value in the Gzip trailer.)

RubyGems generated Gzip Header: 10 bytes
  magic(2) + method(1) + flag(1) + mtime(4) + exflag(1) + os(1) +
  orig_name(0) + comment(0)

Ideally, it must return a GZipReader without meaningless buffering. We have lots of CRuby committers around so let’s fix windows build when we received an error.

Show source
Register or log in to add new notes.