update download contents as more files become available

This commit is contained in:
xenofem 2022-05-24 16:49:48 -04:00
parent 007289ffe5
commit be4decde12
4 changed files with 80 additions and 16 deletions

View file

@ -43,6 +43,17 @@ pub fn file_data_offset(files: &[UploadedFile], idx: usize) -> u64 {
+ files[idx].name.len() as u64
}
pub fn file_data_offsets(files: &[UploadedFile]) -> Vec<u64> {
let mut offsets = Vec::new();
let mut offset: u64 = 0;
for file in files.iter() {
offset += LOCAL_HEADER_SIZE_MINUS_FILENAME + file.name.len() as u64;
offsets.push(offset);
offset += file.size + DATA_DESCRIPTOR_SIZE;
}
offsets
}
fn central_directory_size(files: &[UploadedFile]) -> u64 {
let mut total = 0;
for file in files.iter() {