diff options
| author | Paul Kmiec <[email protected]> | 2023-04-29 16:23:17 -0700 |
|---|---|---|
| committer | Paul Kmiec <[email protected]> | 2023-05-05 09:32:55 -0700 |
| commit | a4a12edab461400da629a42b2847a2242c096d91 (patch) | |
| tree | 7851f5c3d2ed7369241baed70b331998d1a6c0e0 /lib/axlsx/util/zip_command.rb | |
| parent | e5a8faaa70337ffad6ee2a99e00c0ea3b3c69ca0 (diff) | |
| download | caxlsx-a4a12edab461400da629a42b2847a2242c096d91.tar.gz caxlsx-a4a12edab461400da629a42b2847a2242c096d91.zip | |
Write directly to file io instead of buffering the output in memory
Diffstat (limited to 'lib/axlsx/util/zip_command.rb')
| -rw-r--r-- | lib/axlsx/util/zip_command.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/axlsx/util/zip_command.rb b/lib/axlsx/util/zip_command.rb index 00faa942..e43ba03d 100644 --- a/lib/axlsx/util/zip_command.rb +++ b/lib/axlsx/util/zip_command.rb @@ -40,23 +40,21 @@ module Axlsx @current_file = "#{@dir}/#{entry.name}" @files << entry.name FileUtils.mkdir_p(File.dirname(@current_file)) + @io = File.open(@current_file, "wb") end # Write to a buffer that will be written to the current entry def write(content) - @buffer << content + @io << content end alias << write private def write_file - if @current_file - @buffer.rewind - File.open(@current_file, "wb") { |f| f.write @buffer.read } - end + @io.close if @current_file @current_file = nil - @buffer = StringIO.new + @io = nil end def zip_parts(output) |
