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,10 +38,18 @@ pub fn unpack_archive(reader: Box<dyn Read>, output_folder: &Path, quiet: bool)
.link_name()?
.ok_or_else(|| std::io::Error::new(std::io::ErrorKind::InvalidData, "Missing symlink target"))?;
#[cfg(unix)]
std::os::unix::fs::symlink(&target, &full_path)?;
#[cfg(windows)]
std::os::windows::fs::symlink_file(&target, &full_path)?;
if target.is_file() {
#[cfg(unix)]
std::os::unix::fs::symlink(&target, &full_path)?;
#[cfg(windows)]
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 => {
file.unpack_in(output_folder)?;

View File

@ -64,7 +64,21 @@ where
if !quiet {
info(format!("File {} extracted to \"{}\"", idx, file_path.display()));
}
fs::create_dir_all(&file_path)?;
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)?;
}
}
_is_file @ false => {
if let Some(path) = file_path.parent() {

View File

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