Skip to content

Commit 2762408

Browse files
authored
Disable zip compression. (#196)
Improve payload performance by disabling compression.
1 parent 7fb7389 commit 2762408

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/Payload/ZipPayload/PatchableZipPayload.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,14 @@ llvm::Error PatchableZipPayload::addFileToZip(zip_t *zip,
131131
if (src == nullptr)
132132
return extractLibZipError("Creating zip source from data buffer", err);
133133

134-
if (zip_file_add(zip, path.c_str(), src, ZIP_FL_OVERWRITE) < 0) {
135-
auto *archiveErr = zip_get_error(zip);
136-
return extractLibZipError("Adding or replacing file to zip", *archiveErr);
134+
if (int idx = zip_file_add(zip, path.c_str(), src, ZIP_FL_OVERWRITE) < 0) {
135+
if (idx < 0) {
136+
auto *archiveErr = zip_get_error(zip);
137+
return extractLibZipError("Adding or replacing file to zip", *archiveErr);
138+
}
139+
zip_set_file_compression(zip, idx, ZIP_CM_STORE, 1);
137140
}
141+
138142
return llvm::Error::success();
139143
}
140144

lib/Payload/ZipPayload/ZipPayload.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ void ZipPayload::writeZip(llvm::raw_ostream &stream) {
198198
<< " to archive: " << zip_strerror(new_archive) << "\n";
199199
continue;
200200
}
201+
zip_set_file_compression(new_archive, fileIndex, ZIP_CM_STORE, 1);
201202

202203
setFilePermissions(fileIndex, fName, new_archive);
203204
}

0 commit comments

Comments
 (0)