Skip to content

Commit

Permalink
Merge pull request #40123 from summersab/refactor/OC-Server-getRootFo…
Browse files Browse the repository at this point in the history
…lder
  • Loading branch information
skjnldsv authored Mar 15, 2024
2 parents 4905331 + 3f560ae commit 6b4d918
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
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

0 comments on commit 6b4d918

Please sign in to comment.