Merge pull request #13843 from owncloud/fix-files-disabled

Fix disabled files app
This commit is contained in:
Thomas Müller 2015-02-03 16:13:15 +01:00
commit 23c6a0cf99
5 changed files with 65 additions and 2 deletions

View File

@ -28,8 +28,12 @@ class Disable extends Command {
protected function execute(InputInterface $input, OutputInterface $output) {
$appId = $input->getArgument('app-id');
if (\OC_App::isEnabled($appId)) {
\OC_App::disable($appId);
$output->writeln($appId . ' disabled');
try {
\OC_App::disable($appId);
$output->writeln($appId . ' disabled');
} catch(\Exception $e) {
$output->writeln($e->getMessage());
}
} else {
$output->writeln('No such app enabled: ' . $appId);
}

View File

@ -321,6 +321,9 @@ class OC_App {
* @param string $app app
*/
public static function disable($app) {
if($app === 'files') {
throw new \Exception("files can't be disabled.");
}
self::$enabledAppsCache = array(); // flush
// check if app is a shipped app or not. if not delete
\OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));

View File

@ -131,8 +131,12 @@ class AppManager implements IAppManager {
* Disable an app for every user
*
* @param string $appId
* @throws \Exception if app can't be disabled
*/
public function disableApp($appId) {
if($appId === 'files') {
throw new \Exception("files can't be disabled.");
}
$this->appConfig->setValue($appId, 'enabled', 'no');
}
}

View File

@ -13,6 +13,7 @@ use OC\Hooks\Emitter;
use OC\Repair\AssetCache;
use OC\Repair\CleanTags;
use OC\Repair\Collation;
use OC\Repair\EnableFilesApp;
use OC\Repair\FillETags;
use OC\Repair\InnoDB;
use OC\Repair\RepairConfig;
@ -84,6 +85,7 @@ class Repair extends BasicEmitter {
new AssetCache(),
new FillETags(\OC_DB::getConnection()),
new CleanTags(\OC_DB::getConnection()),
new EnableFilesApp(\OC::$server->getConfig()),
);
}

View File

@ -0,0 +1,50 @@
<?php
/**
* Copyright (c) 2015 Morris Jobke <hey@morrisjobke.de>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OC\Repair;
use OC\Hooks\BasicEmitter;
use OC\RepairStep;
use OCP\IConfig;
/**
* Class EnableFilesApp - enables files app if disabled
*
* TODO: remove this with ownCloud 8.1 - this isn't possible anymore with 8.0
*
* @package OC\Repair
*/
class EnableFilesApp extends BasicEmitter implements RepairStep {
/** @var IConfig */
protected $config;
/**
* @param IConfig $config
*/
public function __construct(IConfig $config) {
$this->config = $config;
}
/**
* @return string
*/
public function getName() {
return 'Re-enable file app';
}
/**
* Enables the files app if it is disabled
*/
public function run() {
if ($this->config->getAppValue('files', 'enabled', 'no') !== 'yes') {
$this->config->setAppValue('files', 'enabled', 'yes');
$this->emit('\OC\Repair', 'info', ['Files app was disabled - re-enabled']);
}
}
}