Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor OC\Server::getRootFolder #40123

Merged
merged 2 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lib/private/Streamer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\IRequest;
Expand Down Expand Up @@ -118,7 +119,7 @@ public function addDirRecursive(string $dir, string $internalDir = ''): void {
// prevent absolute dirs
$internalDir = ltrim($internalDir, '/');

$userFolder = \OC::$server->getRootFolder()->get(Filesystem::getRoot());
$userFolder = \OC::$server->get(IRootFolder::class)->get(Filesystem::getRoot());
/** @var Folder $dirNode */
$dirNode = $userFolder->get($dir);
$files = $dirNode->getDirectoryListing();
Expand Down
5 changes: 3 additions & 2 deletions lib/private/legacy/OC_Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Events\BeforeDirectFileDownloadEvent;
use OCP\Files\Events\BeforeZipCreatedEvent;
use OCP\Files\IRootFolder;
use OCP\Lock\ILockingProvider;

/**
Expand Down Expand Up @@ -187,7 +188,7 @@ public static function get($dir, $files, $params = null) {
foreach ($files as $file) {
$file = $dir . '/' . $file;
if (\OC\Files\Filesystem::is_file($file)) {
$userFolder = \OC::$server->getRootFolder()->get(\OC\Files\Filesystem::getRoot());
$userFolder = \OC::$server->get(IRootFolder::class)->get(\OC\Files\Filesystem::getRoot());
$file = $userFolder->get($file);
if ($file instanceof \OC\Files\Node\File) {
try {
Expand Down Expand Up @@ -307,7 +308,7 @@ private static function getSingleFile($view, $dir, $name, $params) {
$file = null;

try {
$userFolder = \OC::$server->getRootFolder()->get(\OC\Files\Filesystem::getRoot());
$userFolder = \OC::$server->get(IRootFolder::class)->get(\OC\Files\Filesystem::getRoot());
$file = $userFolder->get($filename);
if (!$file instanceof \OC\Files\Node\File || !$file->isReadable()) {
http_response_code(403);
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/Preview/BackgroundCleanupJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected function setUp(): void {

$this->connection = \OC::$server->getDatabaseConnection();
$this->previewManager = \OC::$server->getPreviewManager();
$this->rootFolder = \OC::$server->getRootFolder();
$this->rootFolder = \OC::$server->get(IRootFolder::class);
$this->mimeTypeLoader = \OC::$server->getMimeTypeLoader();
$this->timeFactory = \OCP\Server::get(ITimeFactory::class);
}
Expand All @@ -102,7 +102,7 @@ protected function tearDown(): void {

private function getRoot(): Root {
return new Root(
\OC::$server->getRootFolder(),
\OC::$server->get(IRootFolder::class),
\OC::$server->getSystemConfig()
);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/Preview/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace Test\Preview;

use OC\Files\Node\File;
use OCP\Files\IRootFolder;

abstract class Provider extends \Test\TestCase {
/** @var string */
Expand Down Expand Up @@ -137,7 +138,7 @@ protected function prepareTestFile($fileName, $fileContent) {
* @return bool|\OCP\IImage
*/
private function getPreview($provider) {
$file = new File(\OC::$server->getRootFolder(), $this->rootView, $this->imgPath);
$file = new File(\OC::$server->get(IRootFolder::class), $this->rootView, $this->imgPath);
$preview = $provider->getThumbnail($file, $this->maxWidth, $this->maxHeight, $this->scalingUp);

if (get_class($this) === BitmapTest::class && $preview === null) {
Expand Down
6 changes: 3 additions & 3 deletions tests/lib/Share20/DefaultShareProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2514,7 +2514,7 @@ public function testUserDeletedFromGroup($group, $user, $toDelete) {
public function testGetSharesInFolder() {
$userManager = \OC::$server->getUserManager();
$groupManager = \OC::$server->getGroupManager();
$rootFolder = \OC::$server->getRootFolder();
$rootFolder = \OC::$server->get(IRootFolder::class);

$provider = new DefaultShareProvider(
$this->dbConn,
Expand Down Expand Up @@ -2612,7 +2612,7 @@ public function testGetSharesInFolder() {
public function testGetAccessListNoCurrentAccessRequired() {
$userManager = \OC::$server->getUserManager();
$groupManager = \OC::$server->getGroupManager();
$rootFolder = \OC::$server->getRootFolder();
$rootFolder = \OC::$server->get(IRootFolder::class);

$provider = new DefaultShareProvider(
$this->dbConn,
Expand Down Expand Up @@ -2708,7 +2708,7 @@ public function testGetAccessListNoCurrentAccessRequired() {
public function testGetAccessListCurrentAccessRequired() {
$userManager = \OC::$server->getUserManager();
$groupManager = \OC::$server->getGroupManager();
$rootFolder = \OC::$server->getRootFolder();
$rootFolder = \OC::$server->get(IRootFolder::class);

$provider = new DefaultShareProvider(
$this->dbConn,
Expand Down
Loading