Navigation Menu

Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Jun 24, 2014
1 parent 5f5bc60 commit b34fe37
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/droonga/command/serf_event_handler.rb
Expand Up @@ -69,15 +69,15 @@ def live_nodes
end

def output_live_nodes
list_path = Path.live_nodes
path = Path.live_nodes
nodes = live_nodes
file_contents = JSON.pretty_generate(nodes)
FileUtils.mkdir_p(list_path.parent.to_s)
FileUtils.mkdir_p(path.parent.to_s)
# Don't output the file directly to prevent loading of incomplete file!
Tempfile.open(list_path.basename.to_s, list_path.parent.to_s, "w") do |output|
Tempfile.open(path.basename.to_s, path.parent.to_s, "w") do |output|
output.write(file_contents)
output.flush
File.rename(output.path, list_path.to_s)
File.rename(output.path, path.to_s)
end
end
end
Expand Down

0 comments on commit b34fe37

Please sign in to comment.