From 58da7dbf34b3b9dca5acb68fe86214f5a8f2008f Mon Sep 17 00:00:00 2001 From: figsoda Date: Tue, 31 Jan 2023 18:42:32 -0500 Subject: [PATCH] always use zip64 --- src/archive/zip.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/archive/zip.rs b/src/archive/zip.rs index c3ce44b..fa0ab18 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -145,7 +145,9 @@ where W: Write + Seek, { let mut writer = zip::ZipWriter::new(writer); - let options = zip::write::FileOptions::default(); + // always use ZIP64 to allow compression of files larger than 4GB + // the format is widely supported and the extra 20B is negligible in most cases + let options = zip::write::FileOptions::default().large_file(true); let output_handle = Handle::from_path(output_path); #[cfg(not(unix))] @@ -220,15 +222,9 @@ where }; let mut file = fs::File::open(path)?; - let large = file.metadata().map_or( - true, - |metadata| metadata.len() > 0xffffffff, // 4 GB - ); writer.start_file( path.to_str().unwrap(), - options - .large_file(large) - .last_modified_time(get_last_modified_time(&file)), + options.last_modified_time(get_last_modified_time(&file)), )?; io::copy(&mut file, &mut writer)?; }