fix(node): emit hooks on Node::copy()

When calling `Files\Node\Node::copy()`, `Files\View::copy()` gets called,
but `Files\View::fakeRoot` is empty so the hooks are not emitted if no
path is given to `Files\View::shouldEmitHooks()`.

This results in node-related events like `NodeCopiedEvent` not being
fired when copying files via `Files\Node\Node::copy()`.

`Files\View::shouldEmitHooks()` is given a path as parameter in almost
all places except when called from the `copy()` function. This commit
changes it and passes the copy target path.

Fixes: nextcloud/collectives#1756

Signed-off-by: Jonas <jonas@freesources.org>
This commit is contained in:
Jonas 2025-05-20 17:14:05 +02:00 committed by backportbot[bot]
parent c003cbb002
commit 10034c4d15

View file

@ -935,7 +935,7 @@ class View {
try {
$exists = $this->file_exists($target);
if ($this->shouldEmitHooks()) {
if ($this->shouldEmitHooks($target)) {
\OC_Hook::emit(
Filesystem::CLASSNAME,
Filesystem::signal_copy,
@ -975,7 +975,7 @@ class View {
$this->changeLock($target, ILockingProvider::LOCK_SHARED);
$lockTypePath2 = ILockingProvider::LOCK_SHARED;
if ($this->shouldEmitHooks() && $result !== false) {
if ($this->shouldEmitHooks($target) && $result !== false) {
\OC_Hook::emit(
Filesystem::CLASSNAME,
Filesystem::signal_post_copy,