From 1987d871ab4f6b5cc4cbec0a00e9eda8cc2ea416 Mon Sep 17 00:00:00 2001 From: Alejandro Tafalla Date: Sat, 19 Oct 2024 23:43:16 +0200 Subject: [PATCH] Fix copying vendored files when they are symbolic links (#183) Co-authored-by: alikates --- src/cmd/vendor.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/vendor.rs b/src/cmd/vendor.rs index 18081380..add1da55 100644 --- a/src/cmd/vendor.rs +++ b/src/cmd/vendor.rs @@ -757,6 +757,10 @@ pub fn copy_recursively( } let filetype = entry.file_type()?; + let canonical_path_filetype = + std::fs::metadata(std::fs::canonicalize(entry.path()).unwrap()) + .unwrap() + .file_type(); if filetype.is_dir() { copy_recursively( entry.path(), @@ -764,7 +768,7 @@ pub fn copy_recursively( includes, ignore, )?; - } else if filetype.is_symlink() { + } else if filetype.is_symlink() && canonical_path_filetype.is_dir() { let orig = std::fs::read_link(entry.path()); symlink_dir(orig.unwrap(), destination.as_ref().join(entry.file_name()))?; } else {