mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-17 06:30:31 +00:00
Added exception handling for if the directory already exists.
git-svn-id: http://django-avatar.googlecode.com/svn/trunk@12 c76b2324-5f53-0410-85ac-b1078a54aeeb
This commit is contained in:
parent
a3ec3aea8e
commit
94e33d6b70
1 changed files with 4 additions and 1 deletions
|
|
@ -101,7 +101,10 @@ def img(request, email_hash, resize_method=Image.ANTIALIAS):
|
|||
def change(request, extra_context={}, next_override=None):
|
||||
if request.method == "POST":
|
||||
dirname = os.path.join(settings.MEDIA_ROOT, 'avatars')
|
||||
os.makedirs(dirname)
|
||||
try:
|
||||
os.makedirs(dirname)
|
||||
except OSError:
|
||||
pass # The dirs already exist.
|
||||
filename = "%s.jpg" % request.user.avatar.email_hash
|
||||
full_filename = os.path.join(dirname, filename)
|
||||
(destination, destination_path) = tempfile.mkstemp()
|
||||
|
|
|
|||
Loading…
Reference in a new issue