Skip to content

Commit

Permalink
Merge pull request #3335 from fujimotos/sf/atomic-storage
Browse files Browse the repository at this point in the history
storage_local: change LocalStorage.save() to be atomic
  • Loading branch information
ashie committed Apr 19, 2021
2 parents 72267d8 + 9a7cda6 commit 31efe9c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fluent/plugin/storage_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def load

def save
return if @on_memory
tmp_path = @path + '.tmp'
tmp_path = @path + '.tmp.' + Fluent::UniqueId.hex(Fluent::UniqueId.generate)
begin
json_string = Yajl::Encoder.encode(@store, pretty: @pretty_print)
File.open(tmp_path, 'w:utf-8', @mode) { |io| io.write json_string; io.fsync }
Expand Down

0 comments on commit 31efe9c

Please sign in to comment.