Fix zipper for empty files
It was erroring out because it could not mmap an empty file.
--
MOS_MIGRATED_REVID=97338974
diff --git a/third_party/ijar/test/zip_test.sh b/third_party/ijar/test/zip_test.sh
index b3247fd..83ca3f5 100755
--- a/third_party/ijar/test/zip_test.sh
+++ b/third_party/ijar/test/zip_test.sh
@@ -52,6 +52,7 @@
function test_zipper() {
mkdir -p ${TEST_TMPDIR}/test/path/to/some
mkdir -p ${TEST_TMPDIR}/test/some/other/path
+ touch ${TEST_TMPDIR}/test/path/to/some/empty_file
echo "toto" > ${TEST_TMPDIR}/test/path/to/some/file
echo "titi" > ${TEST_TMPDIR}/test/path/to/some/other_file
chmod +x ${TEST_TMPDIR}/test/path/to/some/other_file
diff --git a/third_party/ijar/zip_main.cc b/third_party/ijar/zip_main.cc
index cd5c2f3..aeda237 100644
--- a/third_party/ijar/zip_main.cc
+++ b/third_party/ijar/zip_main.cc
@@ -218,7 +218,7 @@
}
u1 *buffer = builder->NewFile(path, mode_to_zipattr(statst.st_mode));
- if (isdir) {
+ if (isdir || statst.st_size == 0) {
builder->FinishFile(0);
} else {
// mmap the input file and memcpy