diff options
| author | Luis González <lgonzalez@vauxoo.com> | 2018-04-17 13:17:47 +0200 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2018-04-17 14:09:34 +0200 |
| commit | 1328c0960d5e561819f79a04483ff5b88e77df69 (patch) | |
| tree | 854715e2bf248c775da0a51adf31cbe15201624c /odoo/tools | |
| parent | 7a24df4889de386faa69e9f763214427a3eed46f (diff) | |
[IMP] tools: avoid concurrent creation of the session_dir
Instead of:
1. testing the existance
2. creating the directory if not exists
(which would not work if a concurrent creation is done between step 1 and 2)
do:
1. try to create the directory
2. skip if it fails
Ask forgiveness, not permission
Closes #24210
Diffstat (limited to 'odoo/tools')
| -rw-r--r-- | odoo/tools/config.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/odoo/tools/config.py b/odoo/tools/config.py index ec7cc0c0cb1..5e925aba0e2 100644 --- a/odoo/tools/config.py +++ b/odoo/tools/config.py @@ -6,6 +6,7 @@ try: except ImportError: import ConfigParser +import errno import logging import optparse import os @@ -620,9 +621,11 @@ class configmanager(object): @property def session_dir(self): d = os.path.join(self['data_dir'], 'sessions') - if not os.path.exists(d): + try: os.makedirs(d, 0o700) - else: + except OSError as e: + if e.errno != errno.EEXIST: + raise assert os.access(d, os.W_OK), \ "%s: directory is not writable" % d return d |
