From 7eceea9041da680df4c05404971125321630201c Mon Sep 17 00:00:00 2001 From: Dmitry Muhomor Date: Wed, 16 Aug 2023 15:13:06 +0300 Subject: [PATCH] extract_android_ota_payload.py: don't keep temporary payload.bin file It takes up a couple of gigabytes of space per-device. --- .../extract_android_ota_payload.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/external/extract_android_ota_payload/extract_android_ota_payload.py b/external/extract_android_ota_payload/extract_android_ota_payload.py index c56e758..7d02b52 100755 --- a/external/extract_android_ota_payload/extract_android_ota_payload.py +++ b/external/extract_android_ota_payload/extract_android_ota_payload.py @@ -102,10 +102,12 @@ def parse_payload(payload_f, partition, out_f): update_metadata_pb2.InstallOperation.Type.Name(operation.type))) def main(filename, output_dir): + is_tmp_payload_file = False if filename.endswith('.zip'): print("Extracting 'payload.bin' from OTA file...") ota_zf = zipfile.ZipFile(filename) payload_file = open(ota_zf.extract('payload.bin', output_dir), 'rb') + is_tmp_payload_file = True else: payload_file = open(filename, 'rb') @@ -145,6 +147,9 @@ def main(filename, output_dir): out_f.close() os.unlink(fname) + if is_tmp_payload_file: + os.unlink(os.path.join(output_dir, 'payload.bin')) + if __name__ == '__main__': try: filename = sys.argv[1]