aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Summers <18727110+summersab@users.noreply.github.com>2023-08-29 18:50:12 -0500
committerGit'Fellow <12234510+solracsf@users.noreply.github.com>2023-11-10 16:51:05 +0100
commit40edb426a3a6857598ff3f447a85e83e32ff0c32 (patch)
treef079cb61f5ae5d4d8eb127273512a4e8911fed01
parent1d9c482e689a474be8f4010a9a898f16e7a5ae25 (diff)
downloadnextcloud-server-40edb426a3a6857598ff3f447a85e83e32ff0c32.tar.gz
nextcloud-server-40edb426a3a6857598ff3f447a85e83e32ff0c32.zip
Refactor `OC\Server::getRootFolder`
Signed-off-by: Andrew Summers <18727110+summersab@users.noreply.github.com>
-rw-r--r--lib/private/Streamer.php3
-rw-r--r--lib/private/legacy/OC_Files.php5
-rw-r--r--tests/lib/Preview/BackgroundCleanupJobTest.php4
-rw-r--r--tests/lib/Preview/Provider.php3
-rw-r--r--tests/lib/Share20/DefaultShareProviderTest.php6
5 files changed, 12 insertions, 9 deletions
diff --git a/lib/private/Streamer.php b/lib/private/Streamer.php
index aafd3d95dfb..4a88278ed99 100644
--- a/lib/private/Streamer.php
+++ b/lib/private/Streamer.php
@@ -32,6 +32,7 @@ use OC\Files\Filesystem;
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;
@@ -118,7 +119,7 @@ class Streamer {
// 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();
diff --git a/lib/private/legacy/OC_Files.php b/lib/private/legacy/OC_Files.php
index ac0a2bbd0e9..ee3be30948b 100644
--- a/lib/private/legacy/OC_Files.php
+++ b/lib/private/legacy/OC_Files.php
@@ -46,6 +46,7 @@ use OC\Streamer;
use OCP\Lock\ILockingProvider;
use OCP\Files\Events\BeforeZipCreatedEvent;
use OCP\Files\Events\BeforeDirectFileDownloadEvent;
+use OCP\Files\IRootFolder;
use OCP\EventDispatcher\IEventDispatcher;
/**
@@ -187,7 +188,7 @@ class OC_Files {
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 {
@@ -307,7 +308,7 @@ class OC_Files {
$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);
diff --git a/tests/lib/Preview/BackgroundCleanupJobTest.php b/tests/lib/Preview/BackgroundCleanupJobTest.php
index aa15ea7f562..3b95676e470 100644
--- a/tests/lib/Preview/BackgroundCleanupJobTest.php
+++ b/tests/lib/Preview/BackgroundCleanupJobTest.php
@@ -84,7 +84,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
$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);
}
@@ -102,7 +102,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
private function getRoot(): Root {
return new Root(
- \OC::$server->getRootFolder(),
+ \OC::$server->get(IRootFolder::class),
\OC::$server->getSystemConfig()
);
}
diff --git a/tests/lib/Preview/Provider.php b/tests/lib/Preview/Provider.php
index a2e5170c82c..b4b50c873a5 100644
--- a/tests/lib/Preview/Provider.php
+++ b/tests/lib/Preview/Provider.php
@@ -22,6 +22,7 @@
namespace Test\Preview;
use OC\Files\Node\File;
+use OCP\Files\IRootFolder;
abstract class Provider extends \Test\TestCase {
/** @var string */
@@ -137,7 +138,7 @@ abstract class Provider extends \Test\TestCase {
* @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) {
diff --git a/tests/lib/Share20/DefaultShareProviderTest.php b/tests/lib/Share20/DefaultShareProviderTest.php
index 0ce96102a30..afa428014f8 100644
--- a/tests/lib/Share20/DefaultShareProviderTest.php
+++ b/tests/lib/Share20/DefaultShareProviderTest.php
@@ -2514,7 +2514,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
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,
@@ -2612,7 +2612,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
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,
@@ -2708,7 +2708,7 @@ class DefaultShareProviderTest extends \Test\TestCase {
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,