From 5bf02b34cb96a97cb6a8fa383d5c6eab3c34f8da Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Wed, 1 Jul 2015 17:20:02 +0000 Subject: Fix zipper for empty files It was erroring out because it could not mmap an empty file. -- MOS_MIGRATED_REVID=97338974 --- third_party/ijar/test/zip_test.sh | 1 + third_party/ijar/zip_main.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'third_party') diff --git a/third_party/ijar/test/zip_test.sh b/third_party/ijar/test/zip_test.sh index b3247fd60b..83ca3f5e0a 100755 --- a/third_party/ijar/test/zip_test.sh +++ b/third_party/ijar/test/zip_test.sh @@ -52,6 +52,7 @@ function assert_zipper_same_after_unzip() { 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 cd5c2f39be..aeda2370e2 100644 --- a/third_party/ijar/zip_main.cc +++ b/third_party/ijar/zip_main.cc @@ -218,7 +218,7 @@ int create(char *zipfile, char **files, bool flatten, bool verbose) { } 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 -- cgit v1.2.3