From 55063dd8e8e3ae52eb90bdf42e36d979dcbb5010 Mon Sep 17 00:00:00 2001 From: Rafael Vargas Date: Mon, 3 Feb 2020 10:20:15 -0300 Subject: fix: Deno.remove() to properly remove dangling symlinks (#3860) For some reason, the unit tests for Deno.remove() were not being imported to unit_tests.ts and, consequently, not being executed. Thus, I imported them, refactored some existent ones and wrote new ones for the symlink removal case. Since the creation of a symlink is not implemented for Windows yet, assertions that consider this state were added when the tests are executed in this OS. --- cli/ops/fs.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cli/ops') diff --git a/cli/ops/fs.rs b/cli/ops/fs.rs index 61bc06d68..d5ce59f99 100644 --- a/cli/ops/fs.rs +++ b/cli/ops/fs.rs @@ -168,8 +168,9 @@ fn op_remove( let is_sync = args.promise_id.is_none(); blocking_json(is_sync, move || { debug!("op_remove {}", path.display()); - let metadata = fs::metadata(&path)?; - if metadata.is_file() { + let metadata = fs::symlink_metadata(&path)?; + let file_type = metadata.file_type(); + if file_type.is_file() || file_type.is_symlink() { fs::remove_file(&path)?; } else if recursive { remove_dir_all(&path)?; -- cgit v1.2.3