diff --git a/CHANGELOG.md b/CHANGELOG.md index 110ef8c..290eac5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [Unreleased] + +### Changed + +- Verify if paths are links before there are directories (as a link can represent a directory) + +### Fixed + +- Deleting a link pointing to a directory now delete the link instead of the directory content + ## 4.1.2 - 2026-08-01 ### Changed diff --git a/src/Internal/Capabilities/Files/AmbientAuthority.php b/src/Internal/Capabilities/Files/AmbientAuthority.php index 3208845..6824a94 100644 --- a/src/Internal/Capabilities/Files/AmbientAuthority.php +++ b/src/Internal/Capabilities/Files/AmbientAuthority.php @@ -87,8 +87,8 @@ public function list(Path $path): Sequence yield Name::of( $name, match (true) { - $file->isDir() => Kind::directory, $file->isLink() => Kind::link, + $file->isDir() => Kind::directory, default => Kind::file, }, ); @@ -117,8 +117,8 @@ public function kind(Path $path): Attempt } return Attempt::result(match (true) { - \is_dir($path) => Kind::directory, \is_link($path) => Kind::link, + \is_dir($path) => Kind::directory, default => Kind::file, }); } @@ -152,6 +152,10 @@ public function remove(Path $path): Attempt return Attempt::result(SideEffect::identity); } + if (\is_link($path->toString())) { + return $this->unlink($path->toString()); + } + if ($path->directory() && \is_dir($path->toString())) { return $this->rmdir($path->toString()); }