mirror of
https://github.com/ouch-org/ouch.git
synced 2025-07-18 23:50:35 +00:00
Fix folder softlink is not preserved after packing
Signed-off-by: tommady <tommady@users.noreply.github.com>
This commit is contained in:
parent
bbce746666
commit
3858076274
@ -141,9 +141,7 @@ where
|
||||
info(format!("Compressing '{}'", EscapedPathDisplay::new(path)));
|
||||
}
|
||||
|
||||
if path.is_dir() {
|
||||
builder.append_dir(path, path)?;
|
||||
} else if path.is_symlink() && !follow_symlinks {
|
||||
if ((path.is_dir() && path.symlink_metadata()?.is_symlink()) || path.is_symlink()) && !follow_symlinks {
|
||||
let target_path = path.read_link()?;
|
||||
|
||||
let mut header = tar::Header::new_gnu();
|
||||
@ -155,6 +153,8 @@ where
|
||||
.detail("Unexpected error while trying to read link")
|
||||
.detail(format!("Error: {err}."))
|
||||
})?;
|
||||
} else if path.is_dir() {
|
||||
builder.append_dir(path, path)?;
|
||||
} else {
|
||||
let mut file = match fs::File::open(path) {
|
||||
Ok(f) => f,
|
||||
|
@ -242,9 +242,7 @@ where
|
||||
.detail(format!("File at '{path:?}' has a non-UTF-8 name"))
|
||||
})?;
|
||||
|
||||
if metadata.is_dir() {
|
||||
writer.add_directory(entry_name, options)?;
|
||||
} else if path.is_symlink() && !follow_symlinks {
|
||||
if ((path.is_dir() && path.symlink_metadata()?.is_symlink()) || path.is_symlink()) && !follow_symlinks {
|
||||
let target_path = path.read_link()?;
|
||||
let target_name = target_path.to_str().ok_or_else(|| {
|
||||
FinalError::with_title("Zip requires that all directories names are valid UTF-8")
|
||||
@ -259,6 +257,8 @@ where
|
||||
let symlink_options = options.unix_permissions(0o120777);
|
||||
|
||||
writer.add_symlink(entry_name, target_name, symlink_options)?;
|
||||
} else if path.is_dir() {
|
||||
writer.add_directory(entry_name, options)?;
|
||||
} else {
|
||||
#[cfg(not(unix))]
|
||||
let options = if is_executable::is_executable(path) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user