chore: Bug fix: need both internal and output path to determine whether to symlink_dir
This commit is contained in:
parent
2a67534fcb
commit
9d11f4cf68
1 changed files with 13 additions and 8 deletions
21
src/read.rs
21
src/read.rs
|
@ -693,20 +693,25 @@ impl<R: Read + Seek> ZipArchive<R> {
|
||||||
let Ok(target) = try_utf8_to_os_string(target) else {
|
let Ok(target) = try_utf8_to_os_string(target) else {
|
||||||
return Err(ZipError::InvalidArchive("Invalid UTF-8 as symlink target"));
|
return Err(ZipError::InvalidArchive("Invalid UTF-8 as symlink target"));
|
||||||
};
|
};
|
||||||
let target_path: PathBuf = directory.as_ref().join(target.clone());
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
|
let target_path = directory.as_ref().join(target);
|
||||||
std::os::unix::fs::symlink(target_path, outpath.as_path())?;
|
std::os::unix::fs::symlink(target_path, outpath.as_path())?;
|
||||||
}
|
}
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
let target_is_dir = if let Ok(meta) = std::fs::metadata(target_path) {
|
let target_internal_path: PathBuf = target.into();
|
||||||
meta.is_dir()
|
let target_path = directory.as_ref().join(target_internal_path.clone());
|
||||||
} else if let Some(target_in_archive) = self.index_for_name(&target) {
|
let target_is_dir =
|
||||||
self.by_index_raw(target_in_archive)?.is_dir()
|
if let Ok(meta) = std::fs::metadata(target_absolute_path) {
|
||||||
} else {
|
meta.is_dir()
|
||||||
false
|
} else if let Some(target_in_archive) =
|
||||||
};
|
self.index_for_path(&target_internal_path)
|
||||||
|
{
|
||||||
|
self.by_index_raw(target_in_archive)?.is_dir()
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
if target_is_dir {
|
if target_is_dir {
|
||||||
std::os::windows::fs::symlink_dir(target_path, outpath.as_path())?;
|
std::os::windows::fs::symlink_dir(target_path, outpath.as_path())?;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue