From 39d4b938cbf703ec3ad7074b72b374ca1cba272a Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 18 Nov 2021 16:54:39 -0500 Subject: [PATCH] Use new `append_link()` API to handle long symlinks I hit this when exporting Fedora Silverblue, there are some long symlinks in there. Depends: https://github.com/alexcrichton/tar-rs/pull/273 Closes: https://github.com/ostreedev/ostree-rs-ext/issues/162 --- lib/Cargo.toml | 2 +- lib/src/tar/export.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/Cargo.toml b/lib/Cargo.toml index bc928136..ba4d88dd 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -35,7 +35,7 @@ pin-project = "1.0" serde = { features = ["derive"], version = "1.0.125" } serde_json = "1.0.64" structopt = "0.3.21" -tar = "0.4.33" +tar = "0.4.38" tempfile = "3.2.0" tokio = { features = ["full"], version = "1" } tokio-util = { features = ["io-util"], version = "0.6.9" } diff --git a/lib/src/tar/export.rs b/lib/src/tar/export.rs index 2cfadda9..ff9721a6 100644 --- a/lib/src/tar/export.rs +++ b/lib/src/tar/export.rs @@ -231,13 +231,11 @@ impl<'a, W: std::io::Write> OstreeTarWriter<'a, W> { .append_data(&mut h, &path, &mut instream) .with_context(|| format!("Writing regfile {}", checksum))?; } else { - h.set_size(0); - h.set_entry_type(tar::EntryType::Symlink); let context = || format!("Writing content symlink: {}", checksum); - h.set_link_name(meta.symlink_target().unwrap().as_str()) - .with_context(context)?; + h.set_entry_type(tar::EntryType::Symlink); + h.set_size(0); self.out - .append_data(&mut h, &path, &mut std::io::empty()) + .append_link(&mut h, &path, meta.symlink_target().unwrap().as_str()) .with_context(context)?; } }