mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 11:35:45 +00:00
address symlink on zip archive should respect the original mode
Signed-off-by: tommady <tommady@users.noreply.github.com>
This commit is contained in:
parent
69b7c2b7bb
commit
c706a3a9b1
@ -238,9 +238,7 @@ where
|
||||
}
|
||||
};
|
||||
|
||||
#[cfg(unix)]
|
||||
let options = options.unix_permissions(metadata.permissions().mode());
|
||||
|
||||
let mode = metadata.permissions().mode();
|
||||
let entry_name = path.to_str().ok_or_else(|| {
|
||||
FinalError::with_title("Zip requires that all directories names are valid UTF-8")
|
||||
.detail(format!("File at '{path:?}' has a non-UTF-8 name"))
|
||||
@ -257,7 +255,7 @@ where
|
||||
|
||||
// This approach writes the symlink target path as the content of the symlink entry.
|
||||
// We detect symlinks during extraction by checking for the Unix symlink mode (0o120000) in the entry's permissions.
|
||||
let symlink_options = options.unix_permissions(0o120777);
|
||||
let symlink_options = options.unix_permissions(0o120000 | (mode & 0o777));
|
||||
writer.add_symlink(entry_name, target_name, symlink_options)?;
|
||||
} else {
|
||||
#[cfg(not(unix))]
|
||||
@ -269,6 +267,8 @@ where
|
||||
|
||||
let mut file = fs::File::open(path)?;
|
||||
|
||||
#[cfg(unix)]
|
||||
let options = options.unix_permissions(mode);
|
||||
// Updated last modified time
|
||||
let last_modified_time = options.last_modified_time(get_last_modified_time(&file));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user