lib/tasks/zip.rb in buildr-1.2.6 vs lib/tasks/zip.rb in buildr-1.2.7
- old
+ new
@@ -399,26 +399,33 @@
class ZipTask < ArchiveTask
private
def create_from(file_map)
- Zip::ZipFile.open(name, Zip::ZipFile::CREATE) do |zip|
- zip.restore_permissions = true
+ Zip::ZipOutputStream.open name do |zip|
+ seen = {}
mkpath = lambda do |dir|
- unless dir == "." || zip.find_entry(dir)
+ unless dir == "." || seen[dir]
mkpath.call File.dirname(dir)
- zip.mkdir dir
+ zip.put_next_entry dir + '/'
+ seen[dir] = true
end
end
-
+
file_map.each do |path, content|
mkpath.call File.dirname(path)
if content.respond_to?(:call)
- zip.get_output_stream(path) { |output| content.call(output) }
+ zip.put_next_entry path
+ content.call zip
elsif content.nil? || File.directory?(content.to_s)
mkpath.call path
else
- zip.add path, content.to_s
+ zip.put_next_entry path
+ File.open content.to_s, "rb" do |is|
+ while data = is.read(4096)
+ zip << data
+ end
+ end
end
end
end
end