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::getMimeTypeLoader #40148

Closed
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
4 changes: 3 additions & 1 deletion core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

use OCP\Files\IMimeTypeLoader;
use Psr\Log\LoggerInterface;

$application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand());
Expand Down Expand Up @@ -163,7 +165,7 @@
);

$application->add(new OC\Core\Command\Maintenance\DataFingerprint(\OC::$server->getConfig(), new \OC\AppFramework\Utility\TimeFactory()));
$application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->getMimeTypeLoader()));
$application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->get(IMimeTypeLoader::class)));
$application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector()));
$application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Maintenance\UpdateHtaccess());
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function __construct(IStorage $storage) {
}

$this->storageCache = new Storage($storage);
$this->mimetypeLoader = \OC::$server->getMimeTypeLoader();
$this->mimetypeLoader = \OC::$server->get(IMimeTypeLoader::class);
$this->connection = \OC::$server->getDatabaseConnection();
$this->eventDispatcher = \OC::$server->get(IEventDispatcher::class);
$this->querySearchHelper = \OCP\Server::get(QuerySearchHelper::class);
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Cache/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use OC\Files\Storage\Wrapper\Encryption;
use OCP\Files\Cache\IScanner;
use OCP\Files\ForbiddenException;
use OCP\Files\IMimeTypeLoader;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IReliableEtagStorage;
use OCP\IDBConnection;
Expand Down Expand Up @@ -500,7 +501,7 @@ private function handleChildren($path, $recursive, $reuse, $folderId, $lock, &$s
// inserted mimetypes but those weren't available yet inside the transaction
// To make sure to have the updated mime types in such cases,
// we reload them here
\OC::$server->getMimeTypeLoader()->reset();
\OC::$server->get(IMimeTypeLoader::class)->reset();
}
return $childQueue;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Files/Cache/Wrapper/CacheJail.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use OC\Files\Search\SearchBinaryOperator;
use OC\Files\Search\SearchComparison;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\IMimeTypeLoader;
use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchComparison;
use OCP\Files\Search\ISearchOperator;
Expand All @@ -53,7 +54,7 @@ public function __construct($cache, $root) {
parent::__construct($cache);
$this->root = $root;
$this->connection = \OC::$server->getDatabaseConnection();
$this->mimetypeLoader = \OC::$server->getMimeTypeLoader();
$this->mimetypeLoader = \OC::$server->get(IMimeTypeLoader::class);

if ($cache instanceof CacheJail) {
$this->unjailedRoot = $cache->getSourcePath($root);
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Share20/DefaultShareProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\Defaults;
use OCP\Files\Folder;
use OCP\Files\IMimeTypeLoader;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\IConfig;
Expand Down Expand Up @@ -1119,7 +1120,7 @@ private function createShare($data) {
$entryData['permissions'] = $entryData['f_permissions'];
$entryData['parent'] = $entryData['f_parent'];
$share->setNodeCacheEntry(Cache::cacheEntryFromData($entryData,
\OC::$server->getMimeTypeLoader()));
\OC::$server->get(IMimeTypeLoader::class)));
}

$share->setProviderId($this->identifier());
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Preview/BackgroundCleanupJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function setUp(): void {
$this->connection = \OC::$server->getDatabaseConnection();
$this->previewManager = \OC::$server->getPreviewManager();
$this->rootFolder = \OC::$server->getRootFolder();
$this->mimeTypeLoader = \OC::$server->getMimeTypeLoader();
$this->mimeTypeLoader = \OC::$server->get(IMimeTypeLoader::class);
$this->timeFactory = \OCP\Server::get(ITimeFactory::class);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Repair/RepairMimeTypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RepairMimeTypesTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();

$this->mimetypeLoader = \OC::$server->getMimeTypeLoader();
$this->mimetypeLoader = \OC::$server->get(IMimeTypeLoader::class);

/** @var IConfig | \PHPUnit\Framework\MockObject\MockObject $config */
$config = $this->getMockBuilder(IConfig::class)
Expand Down
Loading