Merge branch 'master' of ssh://bitbucket.org/MoonQ/flees

This commit is contained in:
Ville Rantanen
2018-02-18 09:56:49 +02:00
2 changed files with 12 additions and 3 deletions

View File

@@ -314,8 +314,7 @@ def get_share(name, require_auth = True):
"authenticated": authenticated
})
if not os.path.exists(share['path']):
os.makedirs(share['path'])
set_rights(share['path'])
makedirs_rights(share['path'])
return (True,share)
def is_expired(share):
@@ -330,6 +329,16 @@ def print_debug(s):
sys.stderr.write(str(s)+"\n")
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.exists(current_path):
os.mkdir(current_path)
set_rights(current_path)
def set_rights(path):
os.chown(path, app.config['UID'], app.config['GID'])
st = os.stat(path)