Handle zip64 extra fields better

Test: check_target_files_signatures
Bug: 283033491
Change-Id: I7da89f8389c09cc99201cff342483c158bd7e9c1
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 4c0d391..f3e6f1e 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -633,14 +633,17 @@
         return True
     return False
 
-  postinstall_config = common.ReadFromInputFile(input_file, POSTINSTALL_CONFIG)
-  postinstall_config = [
-      line for line in postinstall_config.splitlines() if IsInPartialList(line)]
-  if postinstall_config:
-    postinstall_config = "\n".join(postinstall_config)
-    common.WriteToInputFile(input_file, POSTINSTALL_CONFIG, postinstall_config)
-  else:
-    os.unlink(os.path.join(input_file, POSTINSTALL_CONFIG))
+  if common.DoesInputFileContain(input_file, POSTINSTALL_CONFIG):
+    postinstall_config = common.ReadFromInputFile(
+        input_file, POSTINSTALL_CONFIG)
+    postinstall_config = [
+        line for line in postinstall_config.splitlines() if IsInPartialList(line)]
+    if postinstall_config:
+      postinstall_config = "\n".join(postinstall_config)
+      common.WriteToInputFile(
+          input_file, POSTINSTALL_CONFIG, postinstall_config)
+    else:
+      os.unlink(os.path.join(input_file, POSTINSTALL_CONFIG))
 
   return input_file