chore: Fix CI failure involving conversion to OsString for symlinks (see my comments on #125)
This commit is contained in:
parent
f275acf1d2
commit
c52ec50306
2 changed files with 7 additions and 2 deletions
|
@ -689,14 +689,18 @@ impl<R: Read + Seek> ZipArchive<R> {
|
||||||
if file.is_symlink() && (cfg!(unix) || cfg!(windows)) {
|
if file.is_symlink() && (cfg!(unix) || cfg!(windows)) {
|
||||||
let mut target = Vec::with_capacity(file.size() as usize);
|
let mut target = Vec::with_capacity(file.size() as usize);
|
||||||
file.read_exact(&mut target)?;
|
file.read_exact(&mut target)?;
|
||||||
let target_path: PathBuf = directory.as_ref().join(OsString::try_from(target)?);
|
let target = OsString::from(target.to_string());
|
||||||
|
let target_path: PathBuf = directory.as_ref().join(target);
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
std::os::unix::fs::symlink(target_path, outpath.as_path())?;
|
std::os::unix::fs::symlink(target_path, outpath.as_path())?;
|
||||||
}
|
}
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
if target_path.is_dir() {
|
// symlink_dir must be used if this points to another symlink that points to
|
||||||
|
// a directory.
|
||||||
|
if let Ok(meta) = std::fs::metadata(target_path)
|
||||||
|
&& meta.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 {
|
||||||
std::os::windows::fs::symlink_file(target_path, outpath.as_path())?;
|
std::os::windows::fs::symlink_file(target_path, outpath.as_path())?;
|
||||||
|
|
|
@ -4,6 +4,7 @@ use tempdir::TempDir;
|
||||||
#[test]
|
#[test]
|
||||||
fn repro_old423() -> zip::result::ZipResult<()> {
|
fn repro_old423() -> zip::result::ZipResult<()> {
|
||||||
use std::io;
|
use std::io;
|
||||||
|
use tempdir::TempDir;
|
||||||
use zip::ZipArchive;
|
use zip::ZipArchive;
|
||||||
|
|
||||||
let mut v = Vec::new();
|
let mut v = Vec::new();
|
||||||
|
|
Loading…
Add table
Reference in a new issue