diff --git a/src/archive/zip.rs b/src/archive/zip.rs index b02e6e3..260d307 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -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));