Skip to content
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
20 changes: 14 additions & 6 deletions apps/files_versions/lib/Versions/LegacyVersionsBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,23 @@ private function currentUserHasPermissions(FileInfo $sourceFile, int $permission
throw new NotFoundException("No user logged in");
}

if ($sourceFile->getOwner()?->getUID() !== $currentUserId) {
$nodes = $this->rootFolder->getUserFolder($currentUserId)->getById($sourceFile->getId());
$sourceFile = array_pop($nodes);
if (!$sourceFile) {
throw new NotFoundException("Version file not accessible by current user");
if ($sourceFile->getOwner()?->getUID() === $currentUserId) {
return ($sourceFile->getPermissions() & $permissions) === $permissions;
}

$nodes = $this->rootFolder->getUserFolder($currentUserId)->getById($sourceFile->getId());

Check notice

Code scanning / Psalm

PossiblyNullArgument

Argument 1 of OCP\Files\Folder::getById cannot be null, possibly null value provided

if (count($nodes) === 0) {
throw new NotFoundException("Version file not accessible by current user");
}

foreach ($nodes as $node) {
if (($node->getPermissions() & $permissions) === $permissions) {
return true;
}
}

return ($sourceFile->getPermissions() & $permissions) === $permissions;
return false;
}

public function setMetadataValue(Node $node, int $revision, string $key, string $value): void {
Expand Down