Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor: declare getMount() and getMountsIn() at IRootFolder
Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed Jul 4, 2023
commit 481cbafae30dc5fdaa44615a898375be3b0cd89f
11 changes: 3 additions & 8 deletions lib/private/Files/Cache/QuerySearchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,8 @@ public function searchInCaches(ISearchQuery $searchQuery, array $caches): array
*/
public function getCachesAndMountPointsForSearch(IRootFolder $root, string $path, bool $limitToHome = false): array {
$rootLength = strlen($path);
$storage = null;
if (method_exists($root, 'getMount')) {
/** @var IMountPoint $mount */
$mount = $root->getMount($path);
$storage = $mount->getStorage();
}
$mount = $root->getMount($path);
$storage = $mount->getStorage();
if ($storage === null) {
return [];
}
Expand All @@ -222,8 +218,7 @@ public function getCachesAndMountPointsForSearch(IRootFolder $root, string $path
/** @var IMountPoint[] $mountByMountPoint */
$mountByMountPoint = ['' => $mount];

if (!$limitToHome && method_exists($root, 'getMountsIn')) {
/** @var IMountPoint[] $mounts */
if (!$limitToHome) {
$mounts = $root->getMountsIn($path);
foreach ($mounts as $mount) {
$storage = $mount->getStorage();
Expand Down
8 changes: 2 additions & 6 deletions lib/private/Files/Node/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,8 @@ protected function getAppDataDirectoryName(): string {
* @return array
*/
protected function getByIdInRootMount(int $id): array {
$storage = null;
if (\method_exists($this->root, 'getMount')) {
/** @var IMountPoint $mount */
$mount = $this->root->getMount('');
$storage = $mount->getStorage();
}
$mount = $this->root->getMount('');
$storage = $mount->getStorage();
$cacheEntry = $storage?->getCache($this->path)->get($id);
if (!$cacheEntry) {
return [];
Expand Down
7 changes: 4 additions & 3 deletions lib/private/Files/Node/LazyFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

use OC\Files\Utils\PathHelper;
use OCP\Constants;
use OCP\Files\Mount\IMountPoint;

/**
* Class LazyFolder
Expand Down Expand Up @@ -110,14 +111,14 @@ public function mount($storage, $mountPoint, $arguments = []) {
/**
* @inheritDoc
*/
public function getMount($mountPoint) {
public function getMount(string $mountPoint): IMountPoint {
return $this->__call(__FUNCTION__, func_get_args());
}

/**
* @inheritDoc
* @return IMountPoint[]
*/
public function getMountsIn($mountPoint) {
public function getMountsIn(string $mountPoint): array {
return $this->__call(__FUNCTION__, func_get_args());
}

Expand Down
8 changes: 2 additions & 6 deletions lib/private/Files/Node/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,15 @@ public function mount($storage, $mountPoint, $arguments = []) {
$this->mountManager->addMount($mount);
}

/**
* @param string $mountPoint
* @return \OC\Files\Mount\MountPoint
*/
public function getMount($mountPoint) {
public function getMount(string $mountPoint): IMountPoint {
return $this->mountManager->find($mountPoint);
}

/**
* @param string $mountPoint
* @return \OC\Files\Mount\MountPoint[]
*/
public function getMountsIn($mountPoint) {
public function getMountsIn(string $mountPoint): array {
return $this->mountManager->findIn($mountPoint);
}

Expand Down
13 changes: 13 additions & 0 deletions lib/public/Files/IRootFolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use OC\Hooks\Emitter;
use OC\User\NoUserException;
use OCP\Files\Mount\IMountPoint;

/**
* Interface IRootFolder
Expand Down Expand Up @@ -56,4 +57,16 @@ public function getUserFolder($userId);
* @since 24.0.0
*/
public function getByIdInPath(int $id, string $path);

/**
* @return IMountPoint[]
*
* @since 28.0.0
*/
public function getMountsIn(string $mountPoint): array;

/**
* @since 28.0.0
*/
public function getMount(string $mountPoint): IMountPoint;
}