Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed file rename hook #1003

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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