fix: preserve sanitized dangling-symlink read diagnostics

This commit is contained in:
2026-10-06 03:42:06 +09:00
parent 603a814b80
commit ae19426298
+15 -3
View File
@@ -639,9 +639,21 @@ fn require_access(
write: bool, write: bool,
allow_symlink_directory: bool, allow_symlink_directory: bool,
) -> Result<PathBuf, FsError> { ) -> Result<PathBuf, FsError> {
let resolved = access let resolved = access.resolve_access_path(path).map_err(|error| {
.resolve_access_path(path) // A dangling direct link has no resolved identity, but still needs the
.map_err(|error| map_io(logical, error))?; // 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("<provider-internal target>"),
}
} else {
map_io(logical, error)
}
})?;
let symlink = (resolved != path).then(|| direct_symlink(path)).flatten(); let symlink = (resolved != path).then(|| direct_symlink(path)).flatten();
if let Some(info) = symlink.as_ref() if let Some(info) = symlink.as_ref()
&& !info.target_exists && !info.target_exists