Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Tempfile binary mode on windows #109

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/geminabox.rb
Expand Up @@ -227,6 +227,7 @@ def atomic_write(file_name)
temp_dir = File.join(settings.data, "_temp")
FileUtils.mkdir_p(temp_dir)
temp_file = Tempfile.new("." + File.basename(file_name), temp_dir)
temp_file.binmode
yield temp_file
temp_file.close
File.rename(temp_file.path, file_name)
Expand Down
8 changes: 3 additions & 5 deletions lib/geminabox/incoming_gem.rb
Expand Up @@ -5,11 +5,9 @@ def initialize(gem_data, root_path = Geminabox.settings.data)
end

digest = Digest::SHA1.new
if RbConfig::CONFIG["MAJOR"].to_i <= 1 and RbConfig::CONFIG["MINOR"].to_i <= 8
@tempfile = Tempfile.new("gem")
else
@tempfile = Tempfile.new("gem", :encoding => 'binary')
end

@tempfile = Tempfile.new("gem")
@tempfile.binmode

while data = gem_data.read(1024**2)
@tempfile.write data
Expand Down