added safe mkdir in utils, use utils.mkdir_safe() in backup

This commit is contained in:
Spitap
2022-07-21 17:09:23 +02:00
parent 6f604a5fec
commit 8d02d2a9fb
2 changed files with 11 additions and 2 deletions

View File

@@ -106,6 +106,11 @@ def mkdir(path, mode, uid, gid):
os.chmod(path, mode)
os.chown(path, uid, gid)
def mkdir_safe(path, mode, uid, gid):
"""Create a directory. Safe way (-p)"""
if not os.path.exists(path):
os.makedirs(os.path.abspath(path), mode)
mkdir(path, mode, uid, gid)
def make_password(length=16):
"""Create a random password."""