Skip to content

Commit

Permalink
fix: Properly fetch version from shared files by accessing the owner …
Browse files Browse the repository at this point in the history
…storage version

Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Nov 30, 2023
1 parent 6e3781b commit 8a9ff88
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apps/files_versions/lib/Versions/LegacyVersionsBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
namespace OCA\Files_Versions\Versions;

use OC\Files\View;
use OCA\Files_Sharing\ISharedStorage;
use OCA\Files_Sharing\SharedStorage;
use OCA\Files_Versions\Db\VersionEntity;
use OCA\Files_Versions\Db\VersionsMapper;
Expand Down Expand Up @@ -196,6 +197,14 @@ public function read(IVersion $version) {

public function getVersionFile(IUser $user, FileInfo $sourceFile, $revision): File {
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
$file = $userFolder->get($userFolder->getRelativePath($sourceFile->getPath()));

Check notice

Code scanning / Psalm

PossiblyNullArgument Note

Argument 1 of OCP\Files\Folder::get cannot be null, possibly null value provided
$storage = $file->getStorage();
if ($storage->instanceOfStorage(ISharedStorage::class)) {
/** @var ISharedStorage $storage */
$userFolder = $this->rootFolder->getUserFolder($file->getOwner()->getUID());

Check notice

Code scanning / Psalm

PossiblyNullReference Note

Cannot call method getUID on possibly null value
$user = $this->userManager->get($file->getOwner()?->getUID());

Check notice

Code scanning / Psalm

PossiblyNullArgument Note

Argument 1 of OCP\IUserManager::get cannot be null, possibly null value provided
$sourceFile = $file->getStorage()->getShare()->getNode();

Check failure on line 206 in apps/files_versions/lib/Versions/LegacyVersionsBackend.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedInterfaceMethod

apps/files_versions/lib/Versions/LegacyVersionsBackend.php:206:39: UndefinedInterfaceMethod: Method OCP\Files\Storage\IStorage::getShare does not exist (see https://psalm.dev/181)

Check failure

Code scanning / Psalm

UndefinedInterfaceMethod Error

Method OCP\Files\Storage\IStorage::getShare does not exist
}
$versionFolder = $this->getVersionFolder($user);
/** @var File $file */
$file = $versionFolder->get($userFolder->getRelativePath($sourceFile->getPath()) . '.v' . $revision);
Expand Down

0 comments on commit 8a9ff88

Please sign in to comment.