Issue #10 new

archive#add_file doesn't close the file until the archive is closed

Anonymous created an issue

This code leads to a "too many open files" exception:

require 'zipruby'

File.write("a.txt", "abcd")
File.delete("out.zip") rescue nil

Zip::Archive.open("out.zip", Zip::CREATE) do |archive|
  2000.times do |i|
    puts "Going to add #{i}.txt"
    archive.add_file("#{i}.txt", "a.txt")
  end
end
puts "Done"

I believe that newer versions of libzip fix this by closing the zip_source_file after done reading from it. But it wasn't clear to me how to incorporate a newer libzip into zipruby.

Comments (0)

  1. Log in to comment