mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Append to subdir function for windows mapping
This commit is contained in:
parent
3a763178d7
commit
aaefcb913b
@ -435,12 +435,20 @@ class Helpers:
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@staticmethod
|
def is_subdir(self, server_path, root_dir):
|
||||||
def is_subdir(server_path, root_dir):
|
|
||||||
server_path = os.path.realpath(server_path)
|
server_path = os.path.realpath(server_path)
|
||||||
root_dir = os.path.realpath(root_dir)
|
root_dir = os.path.realpath(root_dir)
|
||||||
|
|
||||||
relative = os.path.relpath(server_path, root_dir)
|
if self.is_os_windows():
|
||||||
|
try:
|
||||||
|
relative = os.path.relpath(server_path, root_dir)
|
||||||
|
except:
|
||||||
|
# Windows will crash out if two paths are on different
|
||||||
|
# Drives We can happily return false if this is the case.
|
||||||
|
# Since two different drives will not be relative to eachother.
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
relative = os.path.relpath(server_path, root_dir)
|
||||||
|
|
||||||
if relative.startswith(os.pardir):
|
if relative.startswith(os.pardir):
|
||||||
return False
|
return False
|
||||||
@ -887,12 +895,15 @@ class Helpers:
|
|||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
logger.debug(f"Created Directory : {path}")
|
logger.debug(f"Created Directory : {path}")
|
||||||
|
return True
|
||||||
|
|
||||||
# directory already exists - non-blocking error
|
# directory already exists - non-blocking error
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
|
return True
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
logger.critical(f"Check generated exception due to permssion error: {e}")
|
logger.critical(f"Check generated exception due to permssion error: {e}")
|
||||||
|
return False
|
||||||
|
|
||||||
def create_self_signed_cert(self, cert_dir=None):
|
def create_self_signed_cert(self, cert_dir=None):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user