Skip to content

Commit

Permalink
disable symlink_path on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed Oct 6, 2016
1 parent 70c1d65 commit 630c854
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions lib/fluent/plugin/out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class FileOutput < Output
config_param :compress, :enum, list: SUPPORTED_COMPRESS, default: :text
desc "Execute compression again even when buffer chunk is already compressed."
config_param :recompress, :bool, default: false
desc "Create symlink to temporary buffered file when buffer_type is file."
desc "Create symlink to temporary buffered file when buffer_type is file (disabled on Windows)."
config_param :symlink_path, :string, default: nil

config_section :format, init: true do
Expand Down Expand Up @@ -132,8 +132,13 @@ def configure(conf)
@formatter = formatter_create(conf: conf.elements('format').first)

if @symlink_path && @buffer.respond_to?(:path)
@buffer.extend SymlinkBufferMixin
@buffer.symlink_path = @symlink_path
if Fluent.windows?
log.warn "symlink_path is unavailable on Windows platform. disabled."
@symlink_path = nil
else
@buffer.extend SymlinkBufferMixin
@buffer.symlink_path = @symlink_path
end
end

@dir_perm = system_config.dir_permission || DIR_PERMISSION
Expand Down
6 changes: 4 additions & 2 deletions test/plugin/test_out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ def create_driver(conf = CONFIG)
b1_path = d.instance.buffer.stage[m1].path
b1_size = File.lstat(b1_path).size

assert File.symlink?("#{TMP_DIR}/full.current.log")
assert_equal d.instance.buffer.stage[m2].path, File.readlink("#{TMP_DIR}/full.current.log")
unless Fluent.windows?
assert File.symlink?("#{TMP_DIR}/full.current.log")
assert_equal d.instance.buffer.stage[m2].path, File.readlink("#{TMP_DIR}/full.current.log")
end

Timecop.freeze(Time.parse("2016-10-04 00:00:06 UTC"))

Expand Down

0 comments on commit 630c854

Please sign in to comment.