From ccf54b9bdb2e7ad115d97354eefab89527a023df Mon Sep 17 00:00:00 2001 From: tinect Date: Wed, 27 Dec 2023 01:23:10 +0100 Subject: [PATCH] feat: [WebDAV] prevent WebDAV Adapter from deleting directories when using delete --- src/WebDAV/WebDAVAdapter.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/WebDAV/WebDAVAdapter.php b/src/WebDAV/WebDAVAdapter.php index cde5a7c39..e97edf7f7 100644 --- a/src/WebDAV/WebDAVAdapter.php +++ b/src/WebDAV/WebDAVAdapter.php @@ -176,6 +176,16 @@ public function readStream(string $path) public function delete(string $path): void { + $fileExists = $this->fileExists($path); + + if ($fileExists === false) { + if ($this->directoryExists($path)) { + throw UnableToDeleteFile::atLocation($path); + } + + return; + } + $location = $this->encodePath($this->prefixer->prefixPath($path)); try {