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]