From aecdc182224c15c9bfdc2921d5e8ca0e1012cc5b Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Mon, 17 Apr 2023 09:52:39 -0700 Subject: [PATCH] Fix duplicate super_empty.img When calling add_img_to_target_files twice, super_empty.img will be written twice, and resulting zip would contain duplicate entries. Test: th Bug: 278522974 Change-Id: I2419d0c4f8b04f876a8cc69a1517f59cab94d75d --- tools/releasetools/add_img_to_target_files.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index e154a0f60a..fe4cc32cf7 100644 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -818,6 +818,9 @@ def AddSuperEmpty(output_zip): """Create a super_empty.img and store it in output_zip.""" img = OutputFile(output_zip, OPTIONS.input_tmp, "IMAGES", "super_empty.img") + if os.path.exists(img.name): + logger.info("super_empty.img already exists; no need to rebuild...") + return build_super_image.BuildSuperImage(OPTIONS.info_dict, img.name) img.Write()