Skip to content
This repository
Browse code

Read files in binary mode. Fixes #14

RubyGems specs files (Marshal and compressed one) were read with default
mode, causing issues since default mode is 'text' on Windows.

Change code to use convenience method Gem.read_binary for that purpose.
  • Loading branch information...
commit 5235fbc7ed224a72d6c75b020d7aa02bced18bb7 1 parent 09f465c
Luis Lavena luislavena authored

Showing 1 changed file with 2 additions and 2 deletions. Show diff stats Hide diff stats

  1. +2 2 lib/rubygems/mirror.rb
4 lib/rubygems/mirror.rb
@@ -32,13 +32,13 @@ def to(*args)
32 32 def update_specs
33 33 specz = to(SPECS_FILE_Z)
34 34 @fetcher.fetch(from(SPECS_FILE_Z), specz)
35   - open(to(SPECS_FILE), 'wb') { |f| f << Gem.gunzip(File.read(specz)) }
  35 + open(to(SPECS_FILE), 'wb') { |f| f << Gem.gunzip(Gem.read_binary(specz)) }
36 36 end
37 37
38 38 def gems
39 39 update_specs unless File.exists?(to(SPECS_FILE))
40 40
41   - gems = Marshal.load(File.read(to(SPECS_FILE)))
  41 + gems = Marshal.load(Gem.read_binary(to(SPECS_FILE)))
42 42 gems.map! do |name, ver, plat|
43 43 # If the platform is ruby, it is not in the gem name
44 44 "#{name}-#{ver}#{"-#{plat}" unless plat == RUBY}.gem"

1 comment on commit 5235fbc

James Tucker
Collaborator
raggi commented on 5235fbc

Thanks Luis!

Please sign in to comment.
Something went wrong with that request. Please try again.