update()
public
Save session state to the session’s FileStore file.
Show source
def update
return unless @hash
begin
lockf = File.open(@path+".lock", File::CREAT|File::RDWR, 0600)
lockf.flock File::LOCK_EX
f = File.open(@path+".new", File::CREAT|File::TRUNC|File::WRONLY, 0600)
for k,v in @hash
f.printf "%s=%s\n", CGI::escape(k), CGI::escape(String(v))
end
f.close
File.rename @path+".new", @path
ensure
f.close if f and !f.closed?
lockf.close if lockf
end
end