# File lib/rubygems/mirror/fetcher.rb, line 44
  def write_file(resp, path)
    FileUtils.mkdir_p File.dirname(path)
    File.open(path, 'wb') do |output|
      resp.read_body { |chunk| output << chunk }
    end
    true
  ensure
    # cleanup incomplete files, rescue perm errors etc, they're being
    # raised already.
    File.delete(path) rescue nil if $!
  end