Prevent sparse-file chunks from repeating zero times

This commit is contained in:
Chris Hennick 2023-05-01 16:06:42 -07:00
parent 69bb01d535
commit 29237770c9
No known key found for this signature in database
GPG key ID: 25653935CC8B6C74

View file

@ -88,7 +88,7 @@ fn do_operation<T>(writer: &mut zip_next::ZipWriter<T>,
let mut bytes = Vec::with_capacity(part.extra_bytes.len() + 1); let mut bytes = Vec::with_capacity(part.extra_bytes.len() + 1);
bytes.push(part.first_byte); bytes.push(part.first_byte);
bytes.extend(part.extra_bytes); bytes.extend(part.extra_bytes);
for (index, byte) in repeat(bytes.iter()).take(part.repeats).flatten().enumerate() { for (index, byte) in repeat(bytes.iter()).take(part.repeats as usize + 1).flatten().enumerate() {
sparse_file[part.start as usize + index] = *byte; sparse_file[part.start as usize + index] = *byte;
} }
} }