summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/command/maintenance/mimetype/updatejs.php (renamed from core/command/maintenance/mimetypesjs.php)43
-rw-r--r--core/register_command.php2
2 files changed, 26 insertions, 19 deletions
diff --git a/core/command/maintenance/mimetypesjs.php b/core/command/maintenance/mimetype/updatejs.php
index 8b01f0acf79..5de75d53a3f 100644
--- a/core/command/maintenance/mimetypesjs.php
+++ b/core/command/maintenance/mimetype/updatejs.php
@@ -18,27 +18,35 @@
*
*/
-namespace OC\Core\Command\Maintenance;
+namespace OC\Core\Command\Maintenance\Mimetype;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-class MimeTypesJS extends Command {
+use OCP\Files\IMimeTypeDetector;
+
+class UpdateJS extends Command {
+
+ /** @var IMimeTypeDetector */
+ protected $mimetypeDetector;
+
+ public function __construct(
+ IMimeTypeDetector $mimetypeDetector
+ ) {
+ parent::__construct();
+ $this->mimetypeDetector = $mimetypeDetector;
+ }
+
protected function configure() {
$this
- ->setName('maintenance:mimetypesjs')
+ ->setName('maintenance:mimetype:update-js')
->setDescription('Update mimetypelist.js');
}
protected function execute(InputInterface $input, OutputInterface $output) {
// Fetch all the aliases
- $aliases = json_decode(file_get_contents(\OC::$SERVERROOT . '/config/mimetypealiases.dist.json'), true);
-
- if (file_exists(\OC::$SERVERROOT . '/config/mimetypealiases.json')) {
- $custom = get_object_vars(json_decode(file_get_contents(\OC::$SERVERROOT . '/config/mimetypealiases.json')));
- $aliases = array_merge($aliases, $custom);
- }
+ $aliases = $this->mimetypeDetector->getAllAliases();
// Remove comments
$keys = array_filter(array_keys($aliases), function($k) {
@@ -49,23 +57,22 @@ class MimeTypesJS extends Command {
}
// Fetch all files
- $dir = new \DirectoryIterator(dirname(__DIR__) . '/../img/filetypes');
+ $dir = new \DirectoryIterator(\OC::$SERVERROOT.'/core/img/filetypes');
$files = [];
foreach($dir as $fileInfo) {
- if ($fileInfo->isFile()) {
- $file = preg_replace('/.[^.]*$/', '', $fileInfo->getFilename());
- $files[] = $file;
- }
+ if ($fileInfo->isFile()) {
+ $file = preg_replace('/.[^.]*$/', '', $fileInfo->getFilename());
+ $files[] = $file;
+ }
}
//Remove duplicates
$files = array_values(array_unique($files));
-
// Fetch all themes!
$themes = [];
- $dirs = new \DirectoryIterator(dirname(__DIR__) . '/../../themes/');
+ $dirs = new \DirectoryIterator(\OC::$SERVERROOT.'/themes/');
foreach($dirs as $dir) {
//Valid theme dir
if ($dir->isFile() || $dir->isDot()) {
@@ -84,7 +91,7 @@ class MimeTypesJS extends Command {
$themeIt = new \DirectoryIterator($themeDir);
foreach ($themeIt as $fileInfo) {
if ($fileInfo->isFile()) {
- $file = preg_replace('/.[^.]*$/', '', $fileInfo->getFilename());
+ $file = preg_replace('/.[^.]*$/', '', $fileInfo->getFilename());
$themes[$theme][] = $file;
}
}
@@ -110,7 +117,7 @@ OC.MimeTypeList={
';
//Output the JS
- file_put_contents(dirname(__DIR__) . '/../js/mimetypelist.js', $js);
+ file_put_contents(\OC::$SERVERROOT.'/core/js/mimetypelist.js', $js);
$output->writeln('<info>mimetypelist.js is updated');
}
diff --git a/core/register_command.php b/core/register_command.php
index 72c7b28e9ae..b79c69c8fd5 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -79,10 +79,10 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
);
$application->add(new OC\Core\Command\Encryption\ShowKeyStorageRoot($util));
- $application->add(new OC\Core\Command\Maintenance\MimeTypesJS());
$application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Maintenance\Repair(new \OC\Repair(\OC\Repair::getRepairSteps()), \OC::$server->getConfig()));
$application->add(new OC\Core\Command\Maintenance\SingleUser(\OC::$server->getConfig()));
+ $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector()));
$application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig()));