Skip to content

Commit

Permalink
Merge pull request #2842 from fluent/revert-1995
Browse files Browse the repository at this point in the history
out_file: Revert #1995 changes
  • Loading branch information
repeatedly committed Feb 26, 2020
2 parents e130ad4 + aee1767 commit e67718f
Showing 1 changed file with 4 additions and 23 deletions.
27 changes: 4 additions & 23 deletions lib/fluent/plugin/out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
require 'fileutils'
require 'zlib'
require 'time'
require 'tempfile'

require 'fluent/plugin/output'
require 'fluent/config/error'
Expand Down Expand Up @@ -229,28 +228,10 @@ def write_without_compression(path, chunk)
end

def write_gzip_with_compression(path, chunk)
if @append
# This code will be removed after zlib/multithread bug is fixed.
# Use Tempfile to avoid broken gzip files: https://github.com/fluent/fluentd/issues/1903
Tempfile.create('out_file-gzip-append') { |temp|
begin
writer = Zlib::GzipWriter.new(temp)
chunk.write_to(writer, compressed: :text)
ensure
writer.finish # avoid zlib finalizer warning
end
temp.rewind

File.open(path, "ab", @file_perm) do |f|
IO.copy_stream(temp, f)
end
}
else
File.open(path, "ab", @file_perm) do |f|
gz = Zlib::GzipWriter.new(f)
chunk.write_to(gz, compressed: :text)
gz.close
end
File.open(path, "ab", @file_perm) do |f|
gz = Zlib::GzipWriter.new(f)
chunk.write_to(gz, compressed: :text)
gz.close
end
end

Expand Down

0 comments on commit e67718f

Please sign in to comment.