mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-07 05:02:41 -04:00
Merge pull request #362 from matrix-org/daniel/raceyraceyfunfun
Fix race creating directories
This commit is contained in:
commit
2fc81af06a
1 changed files with 5 additions and 1 deletions
|
@ -14,6 +14,7 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import errno
|
||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
import sys
|
import sys
|
||||||
|
@ -91,8 +92,11 @@ class Config(object):
|
||||||
@classmethod
|
@classmethod
|
||||||
def ensure_directory(cls, dir_path):
|
def ensure_directory(cls, dir_path):
|
||||||
dir_path = cls.abspath(dir_path)
|
dir_path = cls.abspath(dir_path)
|
||||||
if not os.path.exists(dir_path):
|
try:
|
||||||
os.makedirs(dir_path)
|
os.makedirs(dir_path)
|
||||||
|
except OSError, e:
|
||||||
|
if e.errno != errno.EEXIST:
|
||||||
|
raise
|
||||||
if not os.path.isdir(dir_path):
|
if not os.path.isdir(dir_path):
|
||||||
raise ConfigError(
|
raise ConfigError(
|
||||||
"%s is not a directory" % (dir_path,)
|
"%s is not a directory" % (dir_path,)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue