twrpinstall: Remove unnecessary CloseArchive() calls
The destructor MemoryPackage::~MemoryPackage() will automatically call CloseArchive(), so there is no need to repeat the operation to prevent Recovery from crashing.
Change-Id: Ife5d5818bc603f8709e998b856a1e97bc365fc87
diff --git a/twrpinstall/installcommand.cpp b/twrpinstall/installcommand.cpp
index 2d2bc61..9836014 100755
--- a/twrpinstall/installcommand.cpp
+++ b/twrpinstall/installcommand.cpp
@@ -66,7 +66,6 @@
size);
if (ret != 0) {
printf("Failed to read metadata in update package.\n");
- CloseArchive(zip);
return false;
}
return true;
@@ -213,7 +212,6 @@
binary_entry.uncompressed_length);
if (extract_ret != 0) {
printf("Can't extract %s\n", AB_OTA_PAYLOAD_PROPERTIES);
- CloseArchive(Zip);
return false;
}
diff --git a/twrpinstall/twinstall.cpp b/twrpinstall/twinstall.cpp
index 849b3ad..93164e1 100755
--- a/twrpinstall/twinstall.cpp
+++ b/twrpinstall/twinstall.cpp
@@ -71,13 +71,11 @@
static int Install_Theme(const char* path, ZipArchiveHandle Zip) {
#ifdef TW_OEM_BUILD // We don't do custom themes in OEM builds
- CloseArchive(Zip);
return INSTALL_CORRUPT;
#else
std::string binary_name("ui.xml");
ZipEntry binary_entry;
if (FindEntry(Zip, binary_name, &binary_entry) != 0) {
- CloseArchive(Zip);
return INSTALL_CORRUPT;
}
if (!PartitionManager.Mount_Settings_Storage(true))
@@ -129,7 +127,6 @@
}
int32_t err = ExtractEntryToFile(Zip, &binary_entry, fd);
if (err != 0) {
- CloseArchive(Zip);
LOGERR("Could not extract '%s'\n", UPDATE_BINARY_NAME);
return INSTALL_ERROR;
}
@@ -148,7 +145,6 @@
return INSTALL_ERROR;
}
if (ExtractEntryToFile(Zip, &file_contexts_entry, fd)) {
- CloseArchive(Zip);
LOGERR("Could not extract '%s'\n", output_filename.c_str());
return INSTALL_ERROR;
}
@@ -319,7 +315,6 @@
// Additionally verify the compatibility of the package.
if (!verify_package_compatibility(Zip)) {
gui_err("zip_compatible_err=Zip Treble compatibility error!");
- CloseArchive(Zip);
ret_val = INSTALL_CORRUPT;
} else {
ret_val = Prepare_Update_Binary(Zip);
@@ -363,7 +358,6 @@
LOGINFO("TWRP theme zip\n");
ret_val = Install_Theme(path, Zip);
} else {
- CloseArchive(Zip);
ret_val = INSTALL_CORRUPT;
}
}