Skip to content

Commit d9f85f5

Browse files
committed
Merge branch 'rs/zip-with-uncompressed-size-in-the-header'
Improve compatibility of our zip output to fill uncompressed size in the header, which we can do without seeking back (even though it should not be necessary). * rs/zip-with-uncompressed-size-in-the-header: archive-zip: write uncompressed size into header even with streaming
2 parents bf3f167 + 5ea2c84 commit d9f85f5

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

archive-zip.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static int write_zip_entry(struct archiver_args *args,
240240
(mode & 0111) ? ((mode) << 16) : 0;
241241
if (S_ISREG(mode) && args->compression_level != 0 && size > 0)
242242
method = 8;
243-
compressed_size = size;
243+
compressed_size = (method == 0) ? size : 0;
244244

245245
if (S_ISREG(mode) && type == OBJ_BLOB && !args->convert &&
246246
size > big_file_threshold) {
@@ -313,10 +313,7 @@ static int write_zip_entry(struct archiver_args *args,
313313
copy_le16(header.compression_method, method);
314314
copy_le16(header.mtime, zip_time);
315315
copy_le16(header.mdate, zip_date);
316-
if (flags & ZIP_STREAM)
317-
set_zip_header_data_desc(&header, 0, 0, 0);
318-
else
319-
set_zip_header_data_desc(&header, size, compressed_size, crc);
316+
set_zip_header_data_desc(&header, size, compressed_size, crc);
320317
copy_le16(header.filename_length, pathlen);
321318
copy_le16(header.extra_length, ZIP_EXTRA_MTIME_SIZE);
322319
write_or_die(1, &header, ZIP_LOCAL_HEADER_SIZE);

0 commit comments

Comments
 (0)