YUKI Hiroshi
null+****@clear*****
Tue May 27 17:28:05 JST 2014
YUKI Hiroshi 2014-05-27 17:28:05 +0900 (Tue, 27 May 2014) New Revision: dec997c46b1e5598b9d343eb8612927a8c30dbe3 https://github.com/droonga/droonga-engine/commit/dec997c46b1e5598b9d343eb8612927a8c30dbe3 Message: Doun't touch temporary file outside the block Modified files: bin/droonga-engine-catalog-generate lib/droonga/command/serf_event_handler.rb Modified: bin/droonga-engine-catalog-generate (+3 -3) =================================================================== --- bin/droonga-engine-catalog-generate 2014-05-27 17:20:30 +0900 (1bf4b7f) +++ bin/droonga-engine-catalog-generate 2014-05-27 17:28:05 +0900 (76180b4) @@ -101,11 +101,11 @@ def open_output(path) else # Don't output the file directly to prevent loading of incomplete file! path = Pathname(path) - temp_file = Tempfile.open(path.basename.to_s, path.parent.to_s, "w") do |output| + Tempfile.open(path.basename.to_s, path.parent.to_s, "w") do |output| yield(output) - output.path + output.flush + File.rename(output.path, path.to_s) end - File.rename(temp_file, path.to_s) end end Modified: lib/droonga/command/serf_event_handler.rb (+3 -3) =================================================================== --- lib/droonga/command/serf_event_handler.rb 2014-05-27 17:20:30 +0900 (b17750a) +++ lib/droonga/command/serf_event_handler.rb 2014-05-27 17:28:05 +0900 (b98fcb1) @@ -74,11 +74,11 @@ module Droonga nodes = live_nodes file_contents = JSON.pretty_generate(nodes) # Don't output the file directly to prevent loading of incomplete file! - temp_file = Tempfile.open(list_path.basename.to_s, list_path.parent.to_s, "w") do |output| + Tempfile.open(list_path.basename.to_s, list_path.parent.to_s, "w") do |output| output.write(file_contents) - output.path + output.flush + File.rename(output.path, list_path.to_s) end - File.rename(temp_file, list_path.to_s) end end end -------------- next part -------------- HTML����������������������������... Télécharger