From a157b032916103f9085ee8819c4567230c29d28a Mon Sep 17 00:00:00 2001 From: daitj Date: Thu, 3 Oct 2024 16:34:59 +0300 Subject: [PATCH 1/2] fixes issue with directory names which are uppercase in MTP mount but lowercase on update --- GSL/update.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/GSL/update.py b/GSL/update.py index 3fdc585..17b46b3 100644 --- a/GSL/update.py +++ b/GSL/update.py @@ -71,6 +71,26 @@ 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 + # make new path as it is, as this comes from software update + new_dir_path = os.path.join(path_dir, os.path.basename(current_path)) + 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") @@ -82,6 +102,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) From 47c3acede6bb664d25f8027cd052fb7ec72b1b3e Mon Sep 17 00:00:00 2001 From: daitj Date: Thu, 3 Oct 2024 16:44:45 +0300 Subject: [PATCH 2/2] small bug fix, with child path --- GSL/update.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/GSL/update.py b/GSL/update.py index 17b46b3..279fe4e 100644 --- a/GSL/update.py +++ b/GSL/update.py @@ -82,10 +82,11 @@ def fix_path_case(self, current_path, path_parts=[]): #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 - # make new path as it is, as this comes from software update + # 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)) - os.mkdir(new_dir_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: