Skip to content

Commit

Permalink
Don't call getUid() on null
Browse files Browse the repository at this point in the history
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
  • Loading branch information
solracsf committed Nov 16, 2023
1 parent 8bda5e9 commit 652317e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/files_versions/lib/Listener/FileEventsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,20 @@ public function pre_renameOrCopy_hook(Node $source, Node $target): void {

/**
* Retrieve the path relative to the current user root folder.
* If no user is connected, use the node's owner.
* If no user is connected, try to use the node's owner.
*/
private function getPathForNode(Node $node): ?string {
try {
return $this->rootFolder
->getUserFolder(\OC_User::getUser())
->getRelativePath($node->getPath());
} catch (\Throwable $ex) {
$owner = $node->getOwner();
if ($owner === null) {
return null;
}
return $this->rootFolder
->getUserFolder($node->getOwner()->getUid())
->getUserFolder($owner->getUid())
->getRelativePath($node->getPath());
}
}
Expand Down

0 comments on commit 652317e

Please sign in to comment.