Change Files Scan command to use OC\User\Manager

This commit is contained in:
Bart Visscher 2013-09-02 18:18:12 +02:00
parent 0aba549e7f
commit cafc8cb223
2 changed files with 19 additions and 8 deletions

View File

@ -8,10 +8,19 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
class Scan extends Command class Scan extends Command {
{
protected function configure() /**
{ * @var \OC\User\Manager $userManager
*/
private $userManager;
public function __construct(\OC\User\Manager $userManager) {
$this->userManager = $userManager;
parent::__construct();
}
protected function configure() {
$this $this
->setName('files:scan') ->setName('files:scan')
->setDescription('rescan filesystem') ->setDescription('rescan filesystem')
@ -40,15 +49,17 @@ class Scan extends Command
$scanner->scan(''); $scanner->scan('');
} }
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output) {
{
if ($input->getOption('all')) { if ($input->getOption('all')) {
$users = \OC_User::getUsers(); $users = $this->userManager->search('');
} else { } else {
$users = $input->getArgument('user_id'); $users = $input->getArgument('user_id');
} }
foreach ($users as $user) { foreach ($users as $user) {
if (is_object($user)) {
$user = $user->getUID();
}
$this->scanFiles($user, $output); $this->scanFiles($user, $output);
} }
} }

View File

@ -27,5 +27,5 @@ if (!OC::$CLI) {
$defaults = new OC_Defaults; $defaults = new OC_Defaults;
$application = new Application($defaults->getName(), \OC_Util::getVersionString()); $application = new Application($defaults->getName(), \OC_Util::getVersionString());
$application->add(new OC\Core\Command\Status); $application->add(new OC\Core\Command\Status);
$application->add(new OCA\Files\Command\Scan); $application->add(new OCA\Files\Command\Scan(OC_User::getManager()));
$application->run(); $application->run();