Skip to content

Commit

Permalink
[change] 'Erubis::Engine.load_file()' to rename temporary file instea…
Browse files Browse the repository at this point in the history
…d of using flock
  • Loading branch information
kwatch committed Mar 20, 2011
1 parent 94ea249 commit 2c7f043
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/erubis/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ def self.load_file(filename, properties={})
else
input = File.open(filename, 'rb') {|f| f.read }
engine = self.new(input, properties)
File.open(cachename, 'wb') do |f|
f.flock(File::LOCK_EX)
f.write(engine.src)
f.flush()
end
tmpname = cachename + rand().to_s[1,8]
File.open(tmpname, 'wb') {|f| f.write(engine.src) }
File.rename(tmpname, cachename)
end
engine.src.untaint # ok?
return engine
Expand Down

0 comments on commit 2c7f043

Please sign in to comment.