Skip to content

Commit

Permalink
Merge pull request #354 from figsoda/large
Browse files Browse the repository at this point in the history
zip: fix compression of files larger than 4GB
  • Loading branch information
marcospb19 authored Jan 31, 2023
2 parents bc78e64 + 58da7db commit d36c206
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Categories Used:

- Multi-threaded compression for gzip and snappy using gzp [\#348](/~https://github.com/ouch-org/ouch/pull/348) ([figsoda](/~https://github.com/figsoda))

### Bug fixes
### Bug Fixes

- Fix decompression of zip archives with files larger than 4GB [\#354](/~https://github.com/ouch-org/ouch/pull/354) ([figsoda](/~https://github.com/figsoda))

- Fix handling of unknown extensions during decompression [\#355](/~https://github.com/ouch-org/ouch/pull/355) ([figsoda](/~https://github.com/figsoda))

Expand Down
6 changes: 4 additions & 2 deletions src/archive/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down Expand Up @@ -219,7 +221,7 @@ where
options
};

let mut file = fs::File::open(entry.path())?;
let mut file = fs::File::open(path)?;
writer.start_file(
path.to_str().unwrap(),
options.last_modified_time(get_last_modified_time(&file)),
Expand Down

0 comments on commit d36c206

Please sign in to comment.