fix test case

Signed-off-by: tommady <tommady@users.noreply.github.com>
This commit is contained in:
tommady 2025-07-17 09:11:19 +00:00
parent 13898bbef3
commit 37e2caee36
No known key found for this signature in database
GPG Key ID: 175B664929DF2F2F
3 changed files with 27 additions and 6 deletions

View File

@ -38,11 +38,19 @@ pub fn unpack_archive(reader: Box<dyn Read>, output_folder: &Path, quiet: bool)
.link_name()? .link_name()?
.ok_or_else(|| std::io::Error::new(std::io::ErrorKind::InvalidData, "Missing symlink target"))?; .ok_or_else(|| std::io::Error::new(std::io::ErrorKind::InvalidData, "Missing symlink target"))?;
if target.is_file() {
#[cfg(unix)] #[cfg(unix)]
std::os::unix::fs::symlink(&target, &full_path)?; std::os::unix::fs::symlink(&target, &full_path)?;
#[cfg(windows)] #[cfg(windows)]
std::os::windows::fs::symlink_file(&target, &full_path)?; std::os::windows::fs::symlink_file(&target, &full_path)?;
} }
if target.is_dir() {
#[cfg(unix)]
std::os::unix::fs::symlink(&target, &full_path)?;
#[cfg(windows)]
std::os::windows::fs::symlink_dir(&target, &full_path)?;
}
}
tar::EntryType::Regular | tar::EntryType::Directory => { tar::EntryType::Regular | tar::EntryType::Directory => {
file.unpack_in(output_folder)?; file.unpack_in(output_folder)?;
} }

View File

@ -64,8 +64,22 @@ where
if !quiet { if !quiet {
info(format!("File {} extracted to \"{}\"", idx, file_path.display())); info(format!("File {} extracted to \"{}\"", idx, file_path.display()));
} }
let mode = file.unix_mode();
let is_symlink = mode.is_some_and(|mode| mode & 0o170000 == 0o120000);
if is_symlink {
let mut target = String::new();
file.read_to_string(&mut target)?;
#[cfg(unix)]
std::os::unix::fs::symlink(&target, &file_path)?;
#[cfg(windows)]
std::os::windows::fs::symlink_dir(&target, file_path)?;
} else {
fs::create_dir_all(&file_path)?; fs::create_dir_all(&file_path)?;
} }
}
_is_file @ false => { _is_file @ false => {
if let Some(path) = file_path.parent() { if let Some(path) = file_path.parent() {
if !path.exists() { if !path.exists() {

View File

@ -730,7 +730,6 @@ fn symlink_pack_and_unpack(
.assert() .assert()
.success(); .success();
assert_same_directory(&src_files_path, &dest_files_path, false);
// check the symlink stand still // check the symlink stand still
for f in dest_files_path.as_path().read_dir()? { for f in dest_files_path.as_path().read_dir()? {
let f = f?; let f = f?;