From 90449066985a71bfb5a2cbfe378df4ff5fae452f Mon Sep 17 00:00:00 2001 From: airwoodix Date: Thu, 22 Nov 2018 22:00:41 +0100 Subject: [PATCH] Fix 'force' semantics in 'utils.filesystem.mkdir' --- moulinette/utils/filesystem.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/moulinette/utils/filesystem.py b/moulinette/utils/filesystem.py index 07da4bf7..fab5aa98 100644 --- a/moulinette/utils/filesystem.py +++ b/moulinette/utils/filesystem.py @@ -196,7 +196,13 @@ def mkdir(path, mode=0777, parents=False, uid=None, gid=None, force=False): return # Create directory and set permissions - os.mkdir(path, mode) + try: + os.mkdir(path, mode) + except OSError: + # mimic Python3.2+ os.makedirs exist_ok behaviour + if not force or not os.path.isdir(path): + raise + if uid is not None or gid is not None: chown(path, uid, gid)