diff --git a/src/krux/pages/kapps.py b/src/krux/pages/kapps.py index d82e3090..d72214bc 100644 --- a/src/krux/pages/kapps.py +++ b/src/krux/pages/kapps.py @@ -72,9 +72,13 @@ def _parse_all_flash_apps(self): if file.endswith(MPY_FILE_EXTENSION): # Check if signature file exists for the .mpy file try: - sig_data = open( - flash_path_prefix + file + SIGNATURE_FILE_EXTENSION, "rb" - ).read() + sig_data = None + with open( + flash_path_prefix + file + SIGNATURE_FILE_EXTENSION, + "rb", + buffering=0, + ) as sigfile: + sig_data = sigfile.read() if self._valid_signature( sig_data, sha256(flash_path_prefix + file) ): @@ -196,9 +200,10 @@ def load_sd_kapp(self): # pylint: disable=R1710 # Check signature of .mpy file in SD sig_data = None try: - sig_data = open( - sd_path_prefix + filename + SIGNATURE_FILE_EXTENSION, "rb" - ).read() + with open( + sd_path_prefix + filename + SIGNATURE_FILE_EXTENSION, "rb", buffering=0 + ) as sigfile: + sig_data = sigfile.read() except: self.flash_error(t("Missing signature file")) return MENU_CONTINUE @@ -242,6 +247,7 @@ def load_sd_kapp(self): # pylint: disable=R1710 with open( flash_path_prefix + filename + SIGNATURE_FILE_EXTENSION, "wb", + buffering=0, ) as kapp_sig_file: kapp_sig_file.write(sig_data)