Skip to content

Commit 5c9c2fe

Browse files
committed
fix(trashbin): Fix errors in the log on MOVE operations
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 <[email protected]>
1 parent 32f5f6e commit 5c9c2fe

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/files_trashbin/lib/Sabre/TrashbinPlugin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Sabre\DAV\ServerPlugin;
2121
use Sabre\HTTP\RequestInterface;
2222
use Sabre\HTTP\ResponseInterface;
23+
use Sabre\Uri;
2324

2425
class TrashbinPlugin extends ServerPlugin {
2526
public const TRASHBIN_FILENAME = '{http://nextcloud.org/ns}trashbin-filename';
@@ -146,7 +147,8 @@ public function httpGet(RequestInterface $request, ResponseInterface $response):
146147
public function beforeMove(string $sourcePath, string $destinationPath): bool {
147148
try {
148149
$node = $this->server->tree->getNodeForPath($sourcePath);
149-
$destinationNodeParent = $this->server->tree->getNodeForPath(dirname($destinationPath));
150+
[$destinationDir, ] = Uri\split($destinationPath);
151+
$destinationNodeParent = $this->server->tree->getNodeForPath($destinationDir);
150152
} catch (\Sabre\DAV\Exception $e) {
151153
\OCP\Server::get(LoggerInterface::class)
152154
->error($e->getMessage(), ['app' => 'files_trashbin', 'exception' => $e]);

0 commit comments

Comments
 (0)