diff --git a/src/archive/zip.rs b/src/archive/zip.rs index 9dda3ff..8d23f63 100644 --- a/src/archive/zip.rs +++ b/src/archive/zip.rs @@ -95,9 +95,9 @@ where file.read_to_string(&mut target)?; #[cfg(unix)] - std::os::unix::fs::symlink(&target, &file_path)?; + std::os::unix::fs::symlink(&target, file_path)?; #[cfg(windows)] - std::os::windows::fs::symlink_file(&target, &file_path)?; + std::os::windows::fs::symlink_file(&target, file_path)?; } else { let mut output_file = fs::File::create(file_path)?; io::copy(&mut file, &mut output_file)?; diff --git a/tests/integration.rs b/tests/integration.rs index d380e59..fa5fe5f 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -472,8 +472,16 @@ fn unpack_rar_stdin() -> Result<(), Box> { Ok(()) } -#[test] -fn tar_symlink_pack_and_unpack() { +#[proptest(cases = 25)] +fn symlink_pack_and_unpack( + ext: DirectoryExtension, + #[any(size_range(0..1).lift())] extra_extensions: Vec, +) { + if matches!(ext, DirectoryExtension::SevenZ) { + // Skip 7z because the 7z format does not support symlinks + return Ok(()); + } + let temp_dir = tempdir().unwrap(); let root_path = temp_dir.path(); @@ -501,7 +509,7 @@ fn tar_symlink_pack_and_unpack() { files_path.push(symlink_path); - let archive = &root_path.join("archive.tar"); + let archive = &root_path.join(format!("archive.{}", merge_extensions(&ext, extra_extensions))); crate::utils::cargo_bin() .arg("compress") @@ -518,6 +526,7 @@ fn tar_symlink_pack_and_unpack() { .assert() .success(); + println!("archive: {:?}", archive); assert_same_directory(&src_files_path, &dest_files_path, false); // check the symlink stand still for f in dest_files_path.as_path().read_dir().unwrap() {