Skip to content

Commit

Permalink
Merge pull request #1003 from nextcloud/fix-file-rename-hook
Browse files Browse the repository at this point in the history
Fixed file rename hook
  • Loading branch information
tacruc authored Mar 16, 2023
2 parents 29fab37 + 5def96d commit f07020d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Hooks/FileHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit f07020d

Please sign in to comment.