From c07754891221aa14d0e86a7d71aa6e61087837bd 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 --- Cargo.toml | 3 +++ lib/src/tar/export.rs | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d49afd92..bbd6893b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,3 +7,6 @@ opt-level = 1 # No optimizations are too slow for us. [profile.release] lto = "thin" + +[patch.crates-io] +tar = { path = "../../alexcrichton/tar-rs" } 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)?; } }