Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions GSL/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,27 @@ def __init__(self, changes: list = None, display_name: str = None, eula_url: str
self.is_reinstall = is_reinstall
self.type = type

def fix_path_case(self, current_path, path_parts=[]):
path_dir = os.path.dirname(current_path)
if not os.path.isdir(path_dir):
path_parts.append(os.path.basename(current_path))
# check until a proper directory parent path is found
return self.fix_path_case(path_dir, path_parts)
else:
if len(path_parts) > 0:
#try to check if uppercase director exists
new_dir_path = os.path.join(path_dir, os.path.basename(current_path).upper())
if not os.path.isdir(new_dir_path):
# non existing child directory path found in update or lowercase name is already there
new_dir_path = os.path.join(path_dir, os.path.basename(current_path))
if not os.path.isdir(new_dir_path):
# make new path as it is, as this comes from software update
os.mkdir(new_dir_path)
new_current_path = os.path.join(new_dir_path, path_parts.pop())
return self.fix_path_case(new_current_path, path_parts)
else:
return current_path

def process(self, device_path: str) -> str:
if self.url_is_relative:
raise Exception("Relative URLs are not supported")
Expand All @@ -82,6 +103,7 @@ def process(self, device_path: str) -> str:
if self.md5 != hashlib.md5(resp.content).hexdigest():
raise Exception(f"Failed to download the update {self.name}: MD5 does not match")
filepath = os.path.join(device_path, self.unit_filepath)
filepath = self.fix_path_case(filepath, [])
with open(filepath, "wb") as f:
f.write(resp.content)

Expand Down