summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2008-08-27 21:44:14 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2008-08-27 21:44:14 +0000
commitf58217cc02fe6779a69bdf092ce6095bb368401c (patch)
tree9b52789fad2caa8779fdc81741266ae82711dc7e
parent52672f2b942767e861c65dfbaa3058dc1f1a8303 (diff)
Fixed #8455: a lack of permissions in `MEDIA_ROOT` no longer causes an infinite loop when saving files. Thanks, carljm.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8639 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/core/files/storage.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/django/core/files/storage.py b/django/core/files/storage.py
index 30d9be9f00..a320b8e447 100644
--- a/django/core/files/storage.py
+++ b/django/core/files/storage.py
@@ -1,4 +1,5 @@
import os
+import errno
import urlparse
from django.conf import settings
@@ -161,10 +162,13 @@ class FileSystemStorage(Storage):
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