1
0
mirror of https://github.com/django/django.git synced 2024-12-25 10:35:48 +00:00

Fixed #6984 -- Make sure to load session data from the file (if necessary)

prior to truncating it during a save.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8344 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2008-08-14 03:58:09 +00:00
parent 97a7dab2b1
commit 9d83444f16

View File

@ -71,10 +71,13 @@ class SessionStore(SessionBase):
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC | getattr(os, 'O_BINARY', 0)
if must_create:
flags |= os.O_EXCL
# Because this may trigger a load from storage, we must do it before
# truncating the file to save.
session_data = self._session
try:
fd = os.open(self._key_to_file(self.session_key), flags)
try:
os.write(fd, self.encode(self._session))
os.write(fd, self.encode(session_data))
finally:
os.close(fd)
except OSError, e: