makedirs with chown
This commit is contained in:
13
code/app.py
13
code/app.py
@@ -310,8 +310,7 @@ def get_share(name, require_auth = True):
|
|||||||
"authenticated": authenticated
|
"authenticated": authenticated
|
||||||
})
|
})
|
||||||
if not os.path.exists(share['path']):
|
if not os.path.exists(share['path']):
|
||||||
os.makedirs(share['path'])
|
makedirs_rights(share['path'])
|
||||||
set_rights(share['path'])
|
|
||||||
return (True,share)
|
return (True,share)
|
||||||
|
|
||||||
def is_expired(share):
|
def is_expired(share):
|
||||||
@@ -326,6 +325,16 @@ def print_debug(s):
|
|||||||
sys.stderr.write(str(s)+"\n")
|
sys.stderr.write(str(s)+"\n")
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
|
|
||||||
|
def makedirs_rights(path):
|
||||||
|
# os.makedirs with chown
|
||||||
|
path_list = path.split(os.sep)
|
||||||
|
for p in range(len(path_list)):
|
||||||
|
current_path = os.sep.join(path_list[0:(p+1)])
|
||||||
|
if not os.path.exist(current_path):
|
||||||
|
os.mkdir(current_path)
|
||||||
|
set_rights(current_path)
|
||||||
|
|
||||||
|
|
||||||
def set_rights(path):
|
def set_rights(path):
|
||||||
os.chown(path, app.config['UID'], app.config['GID'])
|
os.chown(path, app.config['UID'], app.config['GID'])
|
||||||
st = os.stat(path)
|
st = os.stat(path)
|
||||||
|
|||||||
Reference in New Issue
Block a user