Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #8455: a lack of permissions in `MEDIA_ROOT` no longer causes a…

…n infinite loop when saving files. Thanks, carljm.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8639 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f58217cc02fe6779a69bdf092ce6095bb368401c 1 parent 52672f2
@jacobian jacobian authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 django/core/files/storage.py
View
12 django/core/files/storage.py
@@ -1,4 +1,5 @@
import os
+import errno
import urlparse
from django.conf import settings
@@ -161,10 +162,13 @@ def _save(self, name, content):
finally:
locks.unlock(fd)
os.close(fd)
- except OSError:
- # Ooops, we need a new file name.
- name = self.get_available_name(name)
- full_path = self.path(name)
+ except OSError, e:
+ if e.errno == errno.EEXIST:
+ # Ooops, the file exists. We need a new file name.
+ name = self.get_available_name(name)
+ full_path = self.path(name)
+ else:
+ raise
else:
# OK, the file save worked. Break out of the loop.
break
Please sign in to comment.
Something went wrong with that request. Please try again.