Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #6984 -- Make sure to load session data from the file (if neces…

…sary)

prior to truncating it during a save.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8344 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9d83444f16c7e289881dca132c5f4f3f8e58d05c 1 parent 97a7dab
@malcolmt malcolmt authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 django/contrib/sessions/backends/file.py
View
5 django/contrib/sessions/backends/file.py
@@ -71,10 +71,13 @@ def save(self, must_create=False):
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:
Please sign in to comment.
Something went wrong with that request. Please try again.