From ae19426298d13d45ab78188dc0ffd7d9a8e2379e Mon Sep 17 00:00:00 2001 From: Hare Date: Tue, 6 Oct 2026 03:42:06 +0900 Subject: [PATCH] fix: preserve sanitized dangling-symlink read diagnostics --- crates/fs-operation/src/local.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/fs-operation/src/local.rs b/crates/fs-operation/src/local.rs index e910e65b8..32b0b4cc7 100644 --- a/crates/fs-operation/src/local.rs +++ b/crates/fs-operation/src/local.rs @@ -639,9 +639,21 @@ fn require_access( write: bool, allow_symlink_directory: bool, ) -> Result { - let resolved = access - .resolve_access_path(path) - .map_err(|error| map_io(logical, error))?; + let resolved = access.resolve_access_path(path).map_err(|error| { + // A dangling direct link has no resolved identity, but still needs the + // existing sanitized repair diagnostic rather than an ordinary missing-file error. + if error.kind() == std::io::ErrorKind::NotFound + && direct_symlink(path).is_some_and(|info| !info.target_exists) + { + FsError::BrokenSymlink { + path: PathBuf::from(logical.as_str()), + link: PathBuf::from(logical.as_str()), + target: PathBuf::from(""), + } + } else { + map_io(logical, error) + } + })?; let symlink = (resolved != path).then(|| direct_symlink(path)).flatten(); if let Some(info) = symlink.as_ref() && !info.target_exists