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:
parent
97a7dab2b1
commit
9d83444f16
|
@ -71,10 +71,13 @@ class SessionStore(SessionBase):
|
||||||
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC | getattr(os, 'O_BINARY', 0)
|
flags = os.O_WRONLY | os.O_CREAT | os.O_TRUNC | getattr(os, 'O_BINARY', 0)
|
||||||
if must_create:
|
if must_create:
|
||||||
flags |= os.O_EXCL
|
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:
|
try:
|
||||||
fd = os.open(self._key_to_file(self.session_key), flags)
|
fd = os.open(self._key_to_file(self.session_key), flags)
|
||||||
try:
|
try:
|
||||||
os.write(fd, self.encode(self._session))
|
os.write(fd, self.encode(session_data))
|
||||||
finally:
|
finally:
|
||||||
os.close(fd)
|
os.close(fd)
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
|
|
Loading…
Reference in New Issue