Fixed internal server errors.
This commit is contained in:
parent
9eb79ad850
commit
9283d70e9e
1 changed files with 8 additions and 8 deletions
|
@ -20,7 +20,7 @@ module Session
|
||||||
path = @path + '/' + client_id.to_s
|
path = @path + '/' + client_id.to_s
|
||||||
FileUtils.mkpath path
|
FileUtils.mkpath path
|
||||||
meta[:last_ping] = Time.new.to_i.to_s
|
meta[:last_ping] = Time.new.to_i.to_s
|
||||||
File.open( path + '/session', 'w' ) { |file|
|
File.open( path + '/session', 'wb' ) { |file|
|
||||||
data = {
|
data = {
|
||||||
:user => {
|
:user => {
|
||||||
:id => session['id'],
|
:id => session['id'],
|
||||||
|
@ -28,7 +28,7 @@ module Session
|
||||||
:meta => meta,
|
:meta => meta,
|
||||||
}
|
}
|
||||||
# puts 'CREATE' + Marshal.dump(data)
|
# puts 'CREATE' + Marshal.dump(data)
|
||||||
file.puts Marshal.dump(data)
|
file.write Marshal.dump(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
# send update to browser
|
# send update to browser
|
||||||
|
@ -55,8 +55,8 @@ module Session
|
||||||
data = self.get(client_id)
|
data = self.get(client_id)
|
||||||
path = @path + '/' + client_id.to_s
|
path = @path + '/' + client_id.to_s
|
||||||
data[:meta][:last_ping] = Time.new.to_i.to_s
|
data[:meta][:last_ping] = Time.new.to_i.to_s
|
||||||
File.open( path + '/session', 'w' ) { |file|
|
File.open( path + '/session', 'wb' ) { |file|
|
||||||
file.puts Marshal.dump(data)
|
file.write Marshal.dump(data)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -65,7 +65,7 @@ module Session
|
||||||
session_file = @path + '/' + client_id.to_s + '/session'
|
session_file = @path + '/' + client_id.to_s + '/session'
|
||||||
data = nil
|
data = nil
|
||||||
return if !File.exist? session_file
|
return if !File.exist? session_file
|
||||||
File.open( session_file, 'r' ) { |file|
|
File.open( session_file, 'rb' ) { |file|
|
||||||
all = ''
|
all = ''
|
||||||
while line = file.gets
|
while line = file.gets
|
||||||
all = all + line
|
all = all + line
|
||||||
|
@ -91,9 +91,9 @@ module Session
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false if !File.directory? path
|
return false if !File.directory? path
|
||||||
File.open( path + 'a-' + filename, 'w' ) { |file|
|
File.open( path + 'a-' + filename, 'wb' ) { |file|
|
||||||
file.flock( File::LOCK_EX )
|
file.flock( File::LOCK_EX )
|
||||||
file.puts data.to_json
|
file.write data.to_json
|
||||||
file.flock( File::LOCK_UN )
|
file.flock( File::LOCK_UN )
|
||||||
file.close
|
file.close
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ module Session
|
||||||
FileUtils.mv( file_old, file_new )
|
FileUtils.mv( file_old, file_new )
|
||||||
data = nil
|
data = nil
|
||||||
all = ''
|
all = ''
|
||||||
File.open( file_new, 'r' ) { |file|
|
File.open( file_new, 'rb' ) { |file|
|
||||||
while line = file.gets
|
while line = file.gets
|
||||||
all = all + line
|
all = all + line
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue