From 5c9c2fe5e2fc6fc62f4704759f73e6bac9dc0c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 25 Aug 2025 16:36:55 +0200 Subject: [PATCH] fix(trashbin): Fix errors in the log on MOVE operations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dirname will return '.' for files at the root, which will cause an Exception that gets logged. Instead use \Sabre\Uri\split like other sabre plugins, to get an empty string for root directory. Signed-off-by: Côme Chilliet --- apps/files_trashbin/lib/Sabre/TrashbinPlugin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php b/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php index 54bb1326966..b4dc7b6b255 100644 --- a/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php +++ b/apps/files_trashbin/lib/Sabre/TrashbinPlugin.php @@ -20,6 +20,7 @@ use Sabre\DAV\Server; use Sabre\DAV\ServerPlugin; use Sabre\HTTP\RequestInterface; use Sabre\HTTP\ResponseInterface; +use Sabre\Uri; class TrashbinPlugin extends ServerPlugin { public const TRASHBIN_FILENAME = '{http://nextcloud.org/ns}trashbin-filename'; @@ -146,7 +147,8 @@ class TrashbinPlugin extends ServerPlugin { public function beforeMove(string $sourcePath, string $destinationPath): bool { try { $node = $this->server->tree->getNodeForPath($sourcePath); - $destinationNodeParent = $this->server->tree->getNodeForPath(dirname($destinationPath)); + [$destinationDir, ] = Uri\split($destinationPath); + $destinationNodeParent = $this->server->tree->getNodeForPath($destinationDir); } catch (\Sabre\DAV\Exception $e) { \OCP\Server::get(LoggerInterface::class) ->error($e->getMessage(), ['app' => 'files_trashbin', 'exception' => $e]);