@@ -26,23 +26,23 @@ |
||
26 | 26 | |
27 | 27 | abstract class Base extends \OC\Core\Command\Base { |
28 | 28 | |
29 | - /** * @var IConfig */ |
|
30 | - protected $config; |
|
29 | + /** * @var IConfig */ |
|
30 | + protected $config; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param string $argumentName |
|
34 | - * @param CompletionContext $context |
|
35 | - * @return string[] |
|
36 | - */ |
|
37 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
38 | - if ($argumentName === 'app') { |
|
39 | - return \OC_App::getAllApps(); |
|
40 | - } |
|
32 | + /** |
|
33 | + * @param string $argumentName |
|
34 | + * @param CompletionContext $context |
|
35 | + * @return string[] |
|
36 | + */ |
|
37 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
38 | + if ($argumentName === 'app') { |
|
39 | + return \OC_App::getAllApps(); |
|
40 | + } |
|
41 | 41 | |
42 | - if ($argumentName === 'name') { |
|
43 | - $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
44 | - return $this->config->getAppKeys($appName); |
|
45 | - } |
|
46 | - return []; |
|
47 | - } |
|
42 | + if ($argumentName === 'name') { |
|
43 | + $appName = $context->getWordAtIndex($context->getWordIndex() - 1); |
|
44 | + return $this->config->getAppKeys($appName); |
|
45 | + } |
|
46 | + return []; |
|
47 | + } |
|
48 | 48 | } |
@@ -76,14 +76,14 @@ |
||
76 | 76 | $configName = $input->getArgument('name'); |
77 | 77 | |
78 | 78 | if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { |
79 | - $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); |
|
79 | + $output->writeln('<comment>Config value '.$configName.' for app '.$appName.' not updated, as it has not been set before.</comment>'); |
|
80 | 80 | return 1; |
81 | 81 | } |
82 | 82 | |
83 | 83 | $configValue = $input->getOption('value'); |
84 | 84 | $this->config->setAppValue($appName, $configName, $configValue); |
85 | 85 | |
86 | - $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>'); |
|
86 | + $output->writeln('<info>Config value '.$configName.' for app '.$appName.' set to '.$configValue.'</info>'); |
|
87 | 87 | return 0; |
88 | 88 | } |
89 | 89 | } |
@@ -29,61 +29,61 @@ |
||
29 | 29 | use Symfony\Component\Console\Output\OutputInterface; |
30 | 30 | |
31 | 31 | class SetConfig extends Base { |
32 | - /** * @var IConfig */ |
|
33 | - protected $config; |
|
32 | + /** * @var IConfig */ |
|
33 | + protected $config; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param IConfig $config |
|
37 | - */ |
|
38 | - public function __construct(IConfig $config) { |
|
39 | - parent::__construct(); |
|
40 | - $this->config = $config; |
|
41 | - } |
|
35 | + /** |
|
36 | + * @param IConfig $config |
|
37 | + */ |
|
38 | + public function __construct(IConfig $config) { |
|
39 | + parent::__construct(); |
|
40 | + $this->config = $config; |
|
41 | + } |
|
42 | 42 | |
43 | - protected function configure() { |
|
44 | - parent::configure(); |
|
43 | + protected function configure() { |
|
44 | + parent::configure(); |
|
45 | 45 | |
46 | - $this |
|
47 | - ->setName('config:app:set') |
|
48 | - ->setDescription('Set an app config value') |
|
49 | - ->addArgument( |
|
50 | - 'app', |
|
51 | - InputArgument::REQUIRED, |
|
52 | - 'Name of the app' |
|
53 | - ) |
|
54 | - ->addArgument( |
|
55 | - 'name', |
|
56 | - InputArgument::REQUIRED, |
|
57 | - 'Name of the config to set' |
|
58 | - ) |
|
59 | - ->addOption( |
|
60 | - 'value', |
|
61 | - null, |
|
62 | - InputOption::VALUE_REQUIRED, |
|
63 | - 'The new value of the config' |
|
64 | - ) |
|
65 | - ->addOption( |
|
66 | - 'update-only', |
|
67 | - null, |
|
68 | - InputOption::VALUE_NONE, |
|
69 | - 'Only updates the value, if it is not set before, it is not being added' |
|
70 | - ) |
|
71 | - ; |
|
72 | - } |
|
46 | + $this |
|
47 | + ->setName('config:app:set') |
|
48 | + ->setDescription('Set an app config value') |
|
49 | + ->addArgument( |
|
50 | + 'app', |
|
51 | + InputArgument::REQUIRED, |
|
52 | + 'Name of the app' |
|
53 | + ) |
|
54 | + ->addArgument( |
|
55 | + 'name', |
|
56 | + InputArgument::REQUIRED, |
|
57 | + 'Name of the config to set' |
|
58 | + ) |
|
59 | + ->addOption( |
|
60 | + 'value', |
|
61 | + null, |
|
62 | + InputOption::VALUE_REQUIRED, |
|
63 | + 'The new value of the config' |
|
64 | + ) |
|
65 | + ->addOption( |
|
66 | + 'update-only', |
|
67 | + null, |
|
68 | + InputOption::VALUE_NONE, |
|
69 | + 'Only updates the value, if it is not set before, it is not being added' |
|
70 | + ) |
|
71 | + ; |
|
72 | + } |
|
73 | 73 | |
74 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
75 | - $appName = $input->getArgument('app'); |
|
76 | - $configName = $input->getArgument('name'); |
|
74 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
75 | + $appName = $input->getArgument('app'); |
|
76 | + $configName = $input->getArgument('name'); |
|
77 | 77 | |
78 | - if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { |
|
79 | - $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); |
|
80 | - return 1; |
|
81 | - } |
|
78 | + if (!in_array($configName, $this->config->getAppKeys($appName)) && $input->hasParameterOption('--update-only')) { |
|
79 | + $output->writeln('<comment>Config value ' . $configName . ' for app ' . $appName . ' not updated, as it has not been set before.</comment>'); |
|
80 | + return 1; |
|
81 | + } |
|
82 | 82 | |
83 | - $configValue = $input->getOption('value'); |
|
84 | - $this->config->setAppValue($appName, $configName, $configValue); |
|
83 | + $configValue = $input->getOption('value'); |
|
84 | + $this->config->setAppValue($appName, $configName, $configValue); |
|
85 | 85 | |
86 | - $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>'); |
|
87 | - return 0; |
|
88 | - } |
|
86 | + $output->writeln('<info>Config value ' . $configName . ' for app ' . $appName . ' set to ' . $configValue . '</info>'); |
|
87 | + return 0; |
|
88 | + } |
|
89 | 89 | } |
@@ -68,7 +68,7 @@ |
||
68 | 68 | try { |
69 | 69 | $mount = $this->globalService->getStorage($mountId); |
70 | 70 | } catch (NotFoundException $e) { |
71 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
71 | + $output->writeln('<error>Mount with id "'.$mountId.' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
72 | 72 | return 404; |
73 | 73 | } |
74 | 74 |
@@ -39,77 +39,77 @@ |
||
39 | 39 | use Symfony\Component\Console\Question\ConfirmationQuestion; |
40 | 40 | |
41 | 41 | class Delete extends Base { |
42 | - /** |
|
43 | - * @var GlobalStoragesService |
|
44 | - */ |
|
45 | - protected $globalService; |
|
42 | + /** |
|
43 | + * @var GlobalStoragesService |
|
44 | + */ |
|
45 | + protected $globalService; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @var UserStoragesService |
|
49 | - */ |
|
50 | - protected $userService; |
|
47 | + /** |
|
48 | + * @var UserStoragesService |
|
49 | + */ |
|
50 | + protected $userService; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var IUserSession |
|
54 | - */ |
|
55 | - protected $userSession; |
|
52 | + /** |
|
53 | + * @var IUserSession |
|
54 | + */ |
|
55 | + protected $userSession; |
|
56 | 56 | |
57 | - /** |
|
58 | - * @var IUserManager |
|
59 | - */ |
|
60 | - protected $userManager; |
|
57 | + /** |
|
58 | + * @var IUserManager |
|
59 | + */ |
|
60 | + protected $userManager; |
|
61 | 61 | |
62 | - public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
63 | - parent::__construct(); |
|
64 | - $this->globalService = $globalService; |
|
65 | - $this->userService = $userService; |
|
66 | - $this->userSession = $userSession; |
|
67 | - $this->userManager = $userManager; |
|
68 | - } |
|
62 | + public function __construct(GlobalStoragesService $globalService, UserStoragesService $userService, IUserSession $userSession, IUserManager $userManager) { |
|
63 | + parent::__construct(); |
|
64 | + $this->globalService = $globalService; |
|
65 | + $this->userService = $userService; |
|
66 | + $this->userSession = $userSession; |
|
67 | + $this->userManager = $userManager; |
|
68 | + } |
|
69 | 69 | |
70 | - protected function configure() { |
|
71 | - $this |
|
72 | - ->setName('files_external:delete') |
|
73 | - ->setDescription('Delete an external mount') |
|
74 | - ->addArgument( |
|
75 | - 'mount_id', |
|
76 | - InputArgument::REQUIRED, |
|
77 | - 'The id of the mount to edit' |
|
78 | - )->addOption( |
|
79 | - 'yes', |
|
80 | - 'y', |
|
81 | - InputOption::VALUE_NONE, |
|
82 | - 'Skip confirmation' |
|
83 | - ); |
|
84 | - parent::configure(); |
|
85 | - } |
|
70 | + protected function configure() { |
|
71 | + $this |
|
72 | + ->setName('files_external:delete') |
|
73 | + ->setDescription('Delete an external mount') |
|
74 | + ->addArgument( |
|
75 | + 'mount_id', |
|
76 | + InputArgument::REQUIRED, |
|
77 | + 'The id of the mount to edit' |
|
78 | + )->addOption( |
|
79 | + 'yes', |
|
80 | + 'y', |
|
81 | + InputOption::VALUE_NONE, |
|
82 | + 'Skip confirmation' |
|
83 | + ); |
|
84 | + parent::configure(); |
|
85 | + } |
|
86 | 86 | |
87 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
88 | - $mountId = $input->getArgument('mount_id'); |
|
89 | - try { |
|
90 | - $mount = $this->globalService->getStorage($mountId); |
|
91 | - } catch (NotFoundException $e) { |
|
92 | - $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
93 | - return 404; |
|
94 | - } |
|
87 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
88 | + $mountId = $input->getArgument('mount_id'); |
|
89 | + try { |
|
90 | + $mount = $this->globalService->getStorage($mountId); |
|
91 | + } catch (NotFoundException $e) { |
|
92 | + $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); |
|
93 | + return 404; |
|
94 | + } |
|
95 | 95 | |
96 | - $noConfirm = $input->getOption('yes'); |
|
96 | + $noConfirm = $input->getOption('yes'); |
|
97 | 97 | |
98 | - if (!$noConfirm) { |
|
99 | - $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
100 | - $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
101 | - $listInput->setOption('output', $input->getOption('output')); |
|
102 | - $listCommand->listMounts(null, [$mount], $listInput, $output); |
|
98 | + if (!$noConfirm) { |
|
99 | + $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); |
|
100 | + $listInput = new ArrayInput([], $listCommand->getDefinition()); |
|
101 | + $listInput->setOption('output', $input->getOption('output')); |
|
102 | + $listCommand->listMounts(null, [$mount], $listInput, $output); |
|
103 | 103 | |
104 | - $questionHelper = $this->getHelper('question'); |
|
105 | - $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); |
|
104 | + $questionHelper = $this->getHelper('question'); |
|
105 | + $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); |
|
106 | 106 | |
107 | - if (!$questionHelper->ask($input, $output, $question)) { |
|
108 | - return 1; |
|
109 | - } |
|
110 | - } |
|
107 | + if (!$questionHelper->ask($input, $output, $question)) { |
|
108 | + return 1; |
|
109 | + } |
|
110 | + } |
|
111 | 111 | |
112 | - $this->globalService->removeStorage($mountId); |
|
113 | - return 0; |
|
114 | - } |
|
112 | + $this->globalService->removeStorage($mountId); |
|
113 | + return 0; |
|
114 | + } |
|
115 | 115 | } |
@@ -33,33 +33,33 @@ |
||
33 | 33 | */ |
34 | 34 | interface IAction extends JsonSerializable { |
35 | 35 | |
36 | - /** |
|
37 | - * @param string $icon absolute URI to an icon |
|
38 | - * @since 12.0 |
|
39 | - */ |
|
40 | - public function setIcon($icon); |
|
36 | + /** |
|
37 | + * @param string $icon absolute URI to an icon |
|
38 | + * @since 12.0 |
|
39 | + */ |
|
40 | + public function setIcon($icon); |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string localized action name, e.g. 'Call' |
|
44 | - * @since 12.0 |
|
45 | - */ |
|
46 | - public function getName(); |
|
42 | + /** |
|
43 | + * @return string localized action name, e.g. 'Call' |
|
44 | + * @since 12.0 |
|
45 | + */ |
|
46 | + public function getName(); |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param string $name localized action name, e.g. 'Call' |
|
50 | - * @since 12.0 |
|
51 | - */ |
|
52 | - public function setName($name); |
|
48 | + /** |
|
49 | + * @param string $name localized action name, e.g. 'Call' |
|
50 | + * @since 12.0 |
|
51 | + */ |
|
52 | + public function setName($name); |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param int $priority priorize actions, high order ones are shown on top |
|
56 | - * @since 12.0 |
|
57 | - */ |
|
58 | - public function setPriority($priority); |
|
54 | + /** |
|
55 | + * @param int $priority priorize actions, high order ones are shown on top |
|
56 | + * @since 12.0 |
|
57 | + */ |
|
58 | + public function setPriority($priority); |
|
59 | 59 | |
60 | - /** |
|
61 | - * @return int priority to priorize actions, high order ones are shown on top |
|
62 | - * @since 12.0 |
|
63 | - */ |
|
64 | - public function getPriority(); |
|
60 | + /** |
|
61 | + * @return int priority to priorize actions, high order ones are shown on top |
|
62 | + * @since 12.0 |
|
63 | + */ |
|
64 | + public function getPriority(); |
|
65 | 65 | } |
@@ -28,27 +28,27 @@ |
||
28 | 28 | */ |
29 | 29 | interface IActionFactory { |
30 | 30 | |
31 | - /** |
|
32 | - * Construct and return a new link action for the contacts menu |
|
33 | - * |
|
34 | - * @since 12.0 |
|
35 | - * |
|
36 | - * @param string $icon full path to the action's icon |
|
37 | - * @param string $name localized name of the action |
|
38 | - * @param string $href target URL |
|
39 | - * @return ILinkAction |
|
40 | - */ |
|
41 | - public function newLinkAction($icon, $name, $href); |
|
31 | + /** |
|
32 | + * Construct and return a new link action for the contacts menu |
|
33 | + * |
|
34 | + * @since 12.0 |
|
35 | + * |
|
36 | + * @param string $icon full path to the action's icon |
|
37 | + * @param string $name localized name of the action |
|
38 | + * @param string $href target URL |
|
39 | + * @return ILinkAction |
|
40 | + */ |
|
41 | + public function newLinkAction($icon, $name, $href); |
|
42 | 42 | |
43 | - /** |
|
44 | - * Construct and return a new email action for the contacts menu |
|
45 | - * |
|
46 | - * @since 12.0 |
|
47 | - * |
|
48 | - * @param string $icon full path to the action's icon |
|
49 | - * @param string $name localized name of the action |
|
50 | - * @param string $email target e-mail address |
|
51 | - * @return ILinkAction |
|
52 | - */ |
|
53 | - public function newEMailAction($icon, $name, $email); |
|
43 | + /** |
|
44 | + * Construct and return a new email action for the contacts menu |
|
45 | + * |
|
46 | + * @since 12.0 |
|
47 | + * |
|
48 | + * @param string $icon full path to the action's icon |
|
49 | + * @param string $name localized name of the action |
|
50 | + * @param string $email target e-mail address |
|
51 | + * @return ILinkAction |
|
52 | + */ |
|
53 | + public function newEMailAction($icon, $name, $email); |
|
54 | 54 | } |
@@ -29,15 +29,15 @@ |
||
29 | 29 | */ |
30 | 30 | interface ILinkAction extends IAction { |
31 | 31 | |
32 | - /** |
|
33 | - * @since 12.0 |
|
34 | - * @param string $href the target URL of the action |
|
35 | - */ |
|
36 | - public function setHref($href); |
|
32 | + /** |
|
33 | + * @since 12.0 |
|
34 | + * @param string $href the target URL of the action |
|
35 | + */ |
|
36 | + public function setHref($href); |
|
37 | 37 | |
38 | - /** |
|
39 | - * @since 12.0 |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function getHref(); |
|
38 | + /** |
|
39 | + * @since 12.0 |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function getHref(); |
|
43 | 43 | } |
@@ -24,44 +24,44 @@ |
||
24 | 24 | use OCP\Files\Search\ISearchComparison; |
25 | 25 | |
26 | 26 | class SearchComparison implements ISearchComparison { |
27 | - /** @var string */ |
|
28 | - private $type; |
|
29 | - /** @var string */ |
|
30 | - private $field; |
|
31 | - /** @var string|integer|\DateTime */ |
|
32 | - private $value; |
|
27 | + /** @var string */ |
|
28 | + private $type; |
|
29 | + /** @var string */ |
|
30 | + private $field; |
|
31 | + /** @var string|integer|\DateTime */ |
|
32 | + private $value; |
|
33 | 33 | |
34 | - /** |
|
35 | - * SearchComparison constructor. |
|
36 | - * |
|
37 | - * @param string $type |
|
38 | - * @param string $field |
|
39 | - * @param \DateTime|int|string $value |
|
40 | - */ |
|
41 | - public function __construct($type, $field, $value) { |
|
42 | - $this->type = $type; |
|
43 | - $this->field = $field; |
|
44 | - $this->value = $value; |
|
45 | - } |
|
34 | + /** |
|
35 | + * SearchComparison constructor. |
|
36 | + * |
|
37 | + * @param string $type |
|
38 | + * @param string $field |
|
39 | + * @param \DateTime|int|string $value |
|
40 | + */ |
|
41 | + public function __construct($type, $field, $value) { |
|
42 | + $this->type = $type; |
|
43 | + $this->field = $field; |
|
44 | + $this->value = $value; |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function getType() { |
|
51 | - return $this->type; |
|
52 | - } |
|
47 | + /** |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function getType() { |
|
51 | + return $this->type; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function getField() { |
|
58 | - return $this->field; |
|
59 | - } |
|
54 | + /** |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function getField() { |
|
58 | + return $this->field; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return \DateTime|int|string |
|
63 | - */ |
|
64 | - public function getValue() { |
|
65 | - return $this->value; |
|
66 | - } |
|
61 | + /** |
|
62 | + * @return \DateTime|int|string |
|
63 | + */ |
|
64 | + public function getValue() { |
|
65 | + return $this->value; |
|
66 | + } |
|
67 | 67 | } |
@@ -25,33 +25,33 @@ |
||
25 | 25 | use OCP\Files\Search\ISearchOperator; |
26 | 26 | |
27 | 27 | class SearchBinaryOperator implements ISearchBinaryOperator { |
28 | - /** @var string */ |
|
29 | - private $type; |
|
30 | - /** @var ISearchOperator[] */ |
|
31 | - private $arguments; |
|
28 | + /** @var string */ |
|
29 | + private $type; |
|
30 | + /** @var ISearchOperator[] */ |
|
31 | + private $arguments; |
|
32 | 32 | |
33 | - /** |
|
34 | - * SearchBinaryOperator constructor. |
|
35 | - * |
|
36 | - * @param string $type |
|
37 | - * @param ISearchOperator[] $arguments |
|
38 | - */ |
|
39 | - public function __construct($type, array $arguments) { |
|
40 | - $this->type = $type; |
|
41 | - $this->arguments = $arguments; |
|
42 | - } |
|
33 | + /** |
|
34 | + * SearchBinaryOperator constructor. |
|
35 | + * |
|
36 | + * @param string $type |
|
37 | + * @param ISearchOperator[] $arguments |
|
38 | + */ |
|
39 | + public function __construct($type, array $arguments) { |
|
40 | + $this->type = $type; |
|
41 | + $this->arguments = $arguments; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function getType() { |
|
48 | - return $this->type; |
|
49 | - } |
|
44 | + /** |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function getType() { |
|
48 | + return $this->type; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return ISearchOperator[] |
|
53 | - */ |
|
54 | - public function getArguments() { |
|
55 | - return $this->arguments; |
|
56 | - } |
|
51 | + /** |
|
52 | + * @return ISearchOperator[] |
|
53 | + */ |
|
54 | + public function getArguments() { |
|
55 | + return $this->arguments; |
|
56 | + } |
|
57 | 57 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | $updatedEntries = $builder->execute(); |
73 | 73 | if ($updatedEntries > 0) { |
74 | - $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | + $out->info('Fixed file share permissions for '.$updatedEntries.' shares'); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | } |
108 | 108 | |
109 | 109 | if ($deletedEntries) { |
110 | - $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | + $out->info('Removed '.$deletedEntries.' shares where the parent did not exist'); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 |
@@ -33,89 +33,89 @@ |
||
33 | 33 | * Repairs shares with invalid data |
34 | 34 | */ |
35 | 35 | class RepairInvalidShares implements IRepairStep { |
36 | - public const CHUNK_SIZE = 200; |
|
37 | - |
|
38 | - /** @var \OCP\IConfig */ |
|
39 | - protected $config; |
|
40 | - |
|
41 | - /** @var \OCP\IDBConnection */ |
|
42 | - protected $connection; |
|
43 | - |
|
44 | - /** |
|
45 | - * @param \OCP\IConfig $config |
|
46 | - * @param \OCP\IDBConnection $connection |
|
47 | - */ |
|
48 | - public function __construct($config, $connection) { |
|
49 | - $this->connection = $connection; |
|
50 | - $this->config = $config; |
|
51 | - } |
|
52 | - |
|
53 | - public function getName() { |
|
54 | - return 'Repair invalid shares'; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * Adjust file share permissions |
|
59 | - */ |
|
60 | - private function adjustFileSharePermissions(IOutput $out) { |
|
61 | - $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE; |
|
62 | - $builder = $this->connection->getQueryBuilder(); |
|
63 | - |
|
64 | - $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask); |
|
65 | - $builder |
|
66 | - ->update('share') |
|
67 | - ->set('permissions', $permsFunc) |
|
68 | - ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file'))) |
|
69 | - ->andWhere($builder->expr()->neq('permissions', $permsFunc)); |
|
70 | - |
|
71 | - $updatedEntries = $builder->execute(); |
|
72 | - if ($updatedEntries > 0) { |
|
73 | - $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Remove shares where the parent share does not exist anymore |
|
79 | - */ |
|
80 | - private function removeSharesNonExistingParent(IOutput $out) { |
|
81 | - $deletedEntries = 0; |
|
82 | - |
|
83 | - $query = $this->connection->getQueryBuilder(); |
|
84 | - $query->select('s1.parent') |
|
85 | - ->from('share', 's1') |
|
86 | - ->where($query->expr()->isNotNull('s1.parent')) |
|
87 | - ->andWhere($query->expr()->isNull('s2.id')) |
|
88 | - ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id')) |
|
89 | - ->groupBy('s1.parent') |
|
90 | - ->setMaxResults(self::CHUNK_SIZE); |
|
91 | - |
|
92 | - $deleteQuery = $this->connection->getQueryBuilder(); |
|
93 | - $deleteQuery->delete('share') |
|
94 | - ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent'))); |
|
95 | - |
|
96 | - $deletedInLastChunk = self::CHUNK_SIZE; |
|
97 | - while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
98 | - $deletedInLastChunk = 0; |
|
99 | - $result = $query->execute(); |
|
100 | - while ($row = $result->fetch()) { |
|
101 | - $deletedInLastChunk++; |
|
102 | - $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent']) |
|
103 | - ->execute(); |
|
104 | - } |
|
105 | - $result->closeCursor(); |
|
106 | - } |
|
107 | - |
|
108 | - if ($deletedEntries) { |
|
109 | - $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | - } |
|
111 | - } |
|
112 | - |
|
113 | - public function run(IOutput $out) { |
|
114 | - $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
115 | - if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { |
|
116 | - $this->adjustFileSharePermissions($out); |
|
117 | - } |
|
118 | - |
|
119 | - $this->removeSharesNonExistingParent($out); |
|
120 | - } |
|
36 | + public const CHUNK_SIZE = 200; |
|
37 | + |
|
38 | + /** @var \OCP\IConfig */ |
|
39 | + protected $config; |
|
40 | + |
|
41 | + /** @var \OCP\IDBConnection */ |
|
42 | + protected $connection; |
|
43 | + |
|
44 | + /** |
|
45 | + * @param \OCP\IConfig $config |
|
46 | + * @param \OCP\IDBConnection $connection |
|
47 | + */ |
|
48 | + public function __construct($config, $connection) { |
|
49 | + $this->connection = $connection; |
|
50 | + $this->config = $config; |
|
51 | + } |
|
52 | + |
|
53 | + public function getName() { |
|
54 | + return 'Repair invalid shares'; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * Adjust file share permissions |
|
59 | + */ |
|
60 | + private function adjustFileSharePermissions(IOutput $out) { |
|
61 | + $mask = \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE; |
|
62 | + $builder = $this->connection->getQueryBuilder(); |
|
63 | + |
|
64 | + $permsFunc = $builder->expr()->bitwiseAnd('permissions', $mask); |
|
65 | + $builder |
|
66 | + ->update('share') |
|
67 | + ->set('permissions', $permsFunc) |
|
68 | + ->where($builder->expr()->eq('item_type', $builder->expr()->literal('file'))) |
|
69 | + ->andWhere($builder->expr()->neq('permissions', $permsFunc)); |
|
70 | + |
|
71 | + $updatedEntries = $builder->execute(); |
|
72 | + if ($updatedEntries > 0) { |
|
73 | + $out->info('Fixed file share permissions for ' . $updatedEntries . ' shares'); |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Remove shares where the parent share does not exist anymore |
|
79 | + */ |
|
80 | + private function removeSharesNonExistingParent(IOutput $out) { |
|
81 | + $deletedEntries = 0; |
|
82 | + |
|
83 | + $query = $this->connection->getQueryBuilder(); |
|
84 | + $query->select('s1.parent') |
|
85 | + ->from('share', 's1') |
|
86 | + ->where($query->expr()->isNotNull('s1.parent')) |
|
87 | + ->andWhere($query->expr()->isNull('s2.id')) |
|
88 | + ->leftJoin('s1', 'share', 's2', $query->expr()->eq('s1.parent', 's2.id')) |
|
89 | + ->groupBy('s1.parent') |
|
90 | + ->setMaxResults(self::CHUNK_SIZE); |
|
91 | + |
|
92 | + $deleteQuery = $this->connection->getQueryBuilder(); |
|
93 | + $deleteQuery->delete('share') |
|
94 | + ->where($deleteQuery->expr()->eq('parent', $deleteQuery->createParameter('parent'))); |
|
95 | + |
|
96 | + $deletedInLastChunk = self::CHUNK_SIZE; |
|
97 | + while ($deletedInLastChunk === self::CHUNK_SIZE) { |
|
98 | + $deletedInLastChunk = 0; |
|
99 | + $result = $query->execute(); |
|
100 | + while ($row = $result->fetch()) { |
|
101 | + $deletedInLastChunk++; |
|
102 | + $deletedEntries += $deleteQuery->setParameter('parent', (int) $row['parent']) |
|
103 | + ->execute(); |
|
104 | + } |
|
105 | + $result->closeCursor(); |
|
106 | + } |
|
107 | + |
|
108 | + if ($deletedEntries) { |
|
109 | + $out->info('Removed ' . $deletedEntries . ' shares where the parent did not exist'); |
|
110 | + } |
|
111 | + } |
|
112 | + |
|
113 | + public function run(IOutput $out) { |
|
114 | + $ocVersionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); |
|
115 | + if (version_compare($ocVersionFromBeforeUpdate, '12.0.0.11', '<')) { |
|
116 | + $this->adjustFileSharePermissions($out); |
|
117 | + } |
|
118 | + |
|
119 | + $this->removeSharesNonExistingParent($out); |
|
120 | + } |
|
121 | 121 | } |