From 5def96d09fac8ed6c718e86cc4cea62646d78119 Mon Sep 17 00:00:00 2001 From: Arne Hamann Date: Thu, 16 Mar 2023 22:42:42 +0100 Subject: [PATCH] Fixed file rename hook Signed-off-by: Arne Hamann --- lib/Hooks/FileHooks.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Hooks/FileHooks.php b/lib/Hooks/FileHooks.php index 8655a7b68..bdd587cd4 100644 --- a/lib/Hooks/FileHooks.php +++ b/lib/Hooks/FileHooks.php @@ -87,18 +87,18 @@ public function register() { // move file: delete then add it again in DB to be sure it's there for all users with access to target file // TODO understand why it's triggered twice and avoid double DB update $this->root->listen('\OC\Files', 'postRename', function(\OCP\Files\Node $source, \OCP\Files\Node $target) { - if ($this->isUserNode($source) and $this->isUserNode($target)) { + if ($this->isUserNode($target)) { if ($target->getType() === FileInfo::TYPE_FILE) { // if moved (parents are different) => update DB with access list if ($source->getParent()->getId() !== $target->getParent()->getId()) { - $this->photofilesService->deleteByFile($target); + $this->photofilesService->deleteByFile($source); $this->photofilesService->addByFile($target); // tracks: nothing to do here because we use fileID } } elseif ($target->getType() === FileInfo::TYPE_FOLDER) { if ($source->getParent()->getId() !== $target->getParent()->getId()) { - $this->photofilesService->deleteByFolder($target); + $this->photofilesService->deleteByFolder($source); $this->photofilesService->addByFolder($target); // tracks: nothing to do here because we use fileID }