mirror of
https://github.com/ouch-org/ouch.git
synced 2025-07-18 23:50:35 +00:00
fix test case
Signed-off-by: tommady <tommady@users.noreply.github.com>
This commit is contained in:
parent
13898bbef3
commit
37e2caee36
@ -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)?;
|
||||
|
@ -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() {
|
||||
|
@ -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?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user