Skip to content

Commit

Permalink
Merge pull request #42891 from nextcloud/artonge/fix/path_resolution_…
Browse files Browse the repository at this point in the history
…in_files_versions_hooks

Improve path resolution in files_version hooks
  • Loading branch information
artonge authored Jan 18, 2024
2 parents d9d222d + 51fa2e3 commit 8314fc5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions apps/files_versions/lib/Listener/FileEventsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,16 +350,24 @@ public function pre_renameOrCopy_hook(Node $source, Node $target): void {
private function getPathForNode(Node $node): ?string {
$user = $this->userSession->getUser()?->getUID();
if ($user) {
return $this->rootFolder
$path = $this->rootFolder
->getUserFolder($user)
->getRelativePath($node->getPath());

if ($path !== null) {
return $path;
}
}

$owner = $node->getOwner()?->getUid();
if ($owner) {
return $this->rootFolder
$path = $this->rootFolder
->getUserFolder($owner)
->getRelativePath($node->getPath());

if ($path !== null) {
return $path;
}
}

return null;
Expand Down

0 comments on commit 8314fc5

Please sign in to comment.