Append to subdir function for windows mapping

This commit is contained in:
amcmanu3 2023-01-30 15:22:40 -05:00
parent 3a763178d7
commit aaefcb913b

View File

@ -435,12 +435,20 @@ class Helpers:
return data
@staticmethod
def is_subdir(server_path, root_dir):
def is_subdir(self, server_path, root_dir):
server_path = os.path.realpath(server_path)
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):
return False
@ -887,12 +895,15 @@ class Helpers:
try:
os.makedirs(path)
logger.debug(f"Created Directory : {path}")
return True
# directory already exists - non-blocking error
except FileExistsError:
pass
return True
except PermissionError as e:
logger.critical(f"Check generated exception due to permssion error: {e}")
return False
def create_self_signed_cert(self, cert_dir=None):