#29890: storage: catch the right exception on concurrent os.mkdirs
------------------------------------------------+------------------------
               Reporter:  mar77i                |          Owner:  nobody
                   Type:  Bug                   |         Status:  new
              Component:  File uploads/storage  |        Version:  2.1
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 My django tests (ran in `--parallel`) raised an exception which Django
 appears to attempt to be dealing with already:

 {{{
 Traceback (most recent call last):
   [...]
   File "[app dir]/models.py", line 56, in create_user
     return self._create_user(email, password, **extra_fields)
   File "[app dir]/models.py", line 50, in _create_user
     user.save(using=self._db)
   File "[app dir]/models.py", line 157, in save
     save=False
   File "[project dir]venv/lib/python3.5/site-
 packages/django/db/models/fields/files.py", line 87, in save
     self.name = self.storage.save(name, content,
 max_length=self.field.max_length)
   File "[project dir]venv/lib/python3.5/site-
 packages/django/core/files/storage.py", line 49, in save
     return self._save(name, content)
   File "[project dir]venv/lib/python3.5/site-
 packages/django/core/files/storage.py", line 236, in _save
     os.makedirs(directory)
   File "/usr/lib/python3.5/os.py", line 241, in makedirs
     mkdir(name, mode)
 FileExistsError: [Errno 17] File exists: '[storage dir]'
 }}}

 Inspecting storage.py showes that os.makedirs() is guarded with a
 try...except block concerning FileNotFoundError, but apparently,
 FileExistsError appears to be what that exception handler was supposed to
 be catching.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29890>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.1b1adc85f6aef39c45f58c8445e1df20%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to