Skip to content

Commit fec04be

Browse files
committed
🐛 Fixed symlink to dir was followed when it shouldn't b
1 parent 14d83c0 commit fec04be

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

cli/src/command/extract.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ where
586586
Err(err) if err.kind() == io::ErrorKind::NotFound => None,
587587
Err(err) => return Err(err),
588588
};
589-
if let Some(existing) = metadata.as_ref() {
589+
if let Some(existing) = &metadata {
590590
match overwrite_strategy {
591591
OverwriteStrategy::Never if !*unlink_first => {
592592
return Err(io::Error::new(
@@ -631,6 +631,11 @@ where
631631
if let Some(parent) = path.parent() {
632632
ensure_directory_components(parent, *unlink_first)?;
633633
}
634+
if let Some(meta) = metadata {
635+
if meta.is_symlink() || (meta.is_file() && entry_kind == DataKind::Directory) {
636+
utils::io::ignore_not_found(utils::fs::remove_path(&path))?;
637+
}
638+
}
634639

635640
let remove_existing = should_overwrite_existing && !unlink_existing;
636641

0 commit comments

Comments
 (0)