Skip to content

Commit

Permalink
fix: symlink support for zip archives
Browse files Browse the repository at this point in the history
This started working with the upgradde of the `zip` crate.
  • Loading branch information
Byron committed May 22, 2024
1 parent cd4de83 commit 7384d8b
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 34 deletions.
104 changes: 82 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions gix-archive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ gix-path = { version = "^0.10.7", path = "../gix-path", optional = true }
gix-date = { version = "^0.8.6", path = "../gix-date" }

flate2 = { version = "1.0.26", optional = true }
zip = { version = "0.6.6", optional = true, default-features = false, features = ["deflate", "time"] }
zip = { version = "1.3.1", optional = true, default-features = false, features = ["deflate", "time"] }
time = { version = "0.3.23", optional = true, default-features = false, features = ["std"] }

thiserror = "1.0.26"
Expand All @@ -42,13 +42,13 @@ tar = { version = "0.4.38", optional = true }
document-features = { version = "0.2.0", optional = true }

[dev-dependencies]
gix-testtools = { path = "../tests/tools"}
gix-odb = { path = "../gix-odb"}
gix-worktree = { path = "../gix-worktree", default-features = false, features = ["attributes"]}
gix-hash = { path = "../gix-hash"}
gix-attributes = { path = "../gix-attributes"}
gix-object = { path = "../gix-object"}
gix-filter = { path = "../gix-filter"}
gix-testtools = { path = "../tests/tools" }
gix-odb = { path = "../gix-odb" }
gix-worktree = { path = "../gix-worktree", default-features = false, features = ["attributes"] }
gix-hash = { path = "../gix-hash" }
gix-attributes = { path = "../gix-attributes" }
gix-object = { path = "../gix-object" }
gix-filter = { path = "../gix-filter" }

[package.metadata.docs.rs]
all-features = true
Expand Down
6 changes: 3 additions & 3 deletions gix-archive/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ where
NextFn: FnMut(&mut Stream) -> Result<Option<Entry<'_>>, gix_worktree_stream::entry::Error>,
{
let compression_level = match opts.format {
Format::Zip { compression_level } => compression_level.map(|lvl| lvl as i32),
Format::Zip { compression_level } => compression_level.map(|lvl| lvl as i64),
_other => return write_stream(stream, next_entry, out, opts),
};

Expand Down Expand Up @@ -161,10 +161,10 @@ fn append_zip_entry<W: std::io::Write + std::io::Seek>(
mut entry: gix_worktree_stream::Entry<'_>,
buf: &mut Vec<u8>,
mtime: zip::DateTime,
compression_level: Option<i32>,
compression_level: Option<i64>,
tree_prefix: Option<&bstr::BString>,
) -> Result<(), Error> {
let file_opts = zip::write::FileOptions::default()
let file_opts = zip::write::FileOptions::<'_, ()>::default()
.compression_method(zip::CompressionMethod::Deflated)
.compression_level(compression_level)
.large_file(entry.bytes_remaining().map_or(true, |len| len > u32::MAX as usize))
Expand Down
2 changes: 1 addition & 1 deletion gix-archive/tests/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ mod from_tree {
);
let mut link = ar.by_name("prefix/symlink-to-a")?;
assert!(!link.is_dir());
assert!(link.is_file(), "no symlink differentiation");
assert!(link.is_symlink(), "symlinks are supported as well");
assert_eq!(
link.unix_mode(),
Some(if cfg!(windows) { 0o100644 } else { 0o120644 }),
Expand Down

0 comments on commit 7384d8b

Please sign in to comment.