mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Merge pull request #177 from airwoodix/fix-mkdir-force-leaf-exists
Fix 'force' semantics in 'utils.filesystem.mkdir'
This commit is contained in:
commit
c2f02cd14b
1 changed files with 7 additions and 1 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue