From 07281be18c78fe50e03553d413753c42ec081928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 28 Nov 2023 16:55:44 +0100 Subject: [PATCH] Use getInternalPath instead of replacement regex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/Listeners/NodeRenamedListener.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Listeners/NodeRenamedListener.php b/lib/Listeners/NodeRenamedListener.php index df2f4d7ef..0068cab52 100644 --- a/lib/Listeners/NodeRenamedListener.php +++ b/lib/Listeners/NodeRenamedListener.php @@ -54,8 +54,13 @@ public function handle(Event $event): void { if (($target instanceof Folder) && $sourceStorage->instanceOfStorage(GroupFolderStorage::class) && $targetStorage->instanceOfStorage(GroupFolderStorage::class)) { - $sourcePath = preg_replace('/^'.preg_quote($source->getParent()->getMountPoint()->getMountPoint(), '/').'/', '', $source->getPath()); - $targetPath = preg_replace('/^'.preg_quote($target->getMountPoint()->getMountPoint(), '/').'/', '', $target->getPath()); + // Get internal path on parent to avoid NotFoundException + $sourcePath = $source->getParent()->getInternalPath(); + if ($sourcePath !== '') { + $sourcePath .= '/'; + } + $sourcePath .= $source->getName(); + $targetPath = $target->getInternalPath(); $this->trashManager->updateTrashedChildren($sourceStorage->getFolderId(), $targetStorage->getFolderId(), $sourcePath, $targetPath); } }