Skip to content

Commit

Permalink
fix(files_versions): Explicitly check for user or owner before call g…
Browse files Browse the repository at this point in the history
…etUserFolder

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>

Fix typo

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
  • Loading branch information
solracsf committed Nov 25, 2023
1 parent 28e0ccf commit f42963d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions apps/files_versions/lib/Listener/FileEventsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,18 +354,20 @@ public function pre_renameOrCopy_hook(Node $source, Node $target): void {
* If no user is connected, try to use the node's owner.
*/
private function getPathForNode(Node $node): ?string {
try {
$user = \OC_User::getUser();
if (!empty($user)) {
return $this->rootFolder
->getUserFolder(\OC_User::getUser())
->getUserFolder($user)
->getRelativePath($node->getPath());
} catch (\Throwable $ex) {
$owner = $node->getOwner();
if ($owner === null) {
return null;
}
}

$owner = $node->getOwner();
if (!empty($owner)) {
return $this->rootFolder
->getUserFolder($owner->getUid())
->getRelativePath($node->getPath());
}

return null;
}
}

0 comments on commit f42963d

Please sign in to comment.