Skip to content

Commit

Permalink
Fix jruby long link untar problem
Browse files Browse the repository at this point in the history
The tar crate is currently truncating filenames that are using the GNU "long link" feature alexcrichton/tar-rs#369.

The fix is to shell out to system tar instead.
  • Loading branch information
schneems committed Jul 3, 2024
1 parent 9e64b44 commit aa44be3
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions shared/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use bullet_stream::state::SubBullet;
use bullet_stream::Print;
use flate2::read::GzDecoder;
use fs_err::{File, PathExt};
use fun_run::CommandWithName;
use std::io::{Read, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf};
use tar::Archive;
use std::process::Command;

mod base_image;
mod download_ruby_version;
Expand All @@ -22,10 +22,19 @@ impl AsRef<Path> for TarDownloadPath {
}

pub fn untar_to_dir(tar_path: &TarDownloadPath, workspace: &Path) -> Result<(), Error> {
let file = fs_err::File::open(tar_path.as_ref()).map_err(Error::FsError)?;
let tar = GzDecoder::new(file);
let mut archive = Archive::new(tar);
archive.unpack(workspace).map_err(Error::FsError)?;
fs_err::create_dir_all(workspace).map_err(Error::FsError)?;

// Shelling out due to https://github.com/alexcrichton/tar-rs/issues/369
let mut cmd = Command::new("bash");
cmd.arg("-c");
cmd.arg(
[
format!("cd {}", workspace.display()),
format!("tar xzf {}", tar_path.as_ref().display()),
]
.join(" && "),
);
cmd.named_output().map_err(Error::CmdError)?;

Ok(())
}
Expand Down

0 comments on commit aa44be3

Please sign in to comment.