Skip to content

Commit

Permalink
Change Files Scan command to use OC\User\Manager
Browse files Browse the repository at this point in the history
  • Loading branch information
bartv2 committed Sep 2, 2013
1 parent 0aba549 commit cafc8cb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions apps/files/command/scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class Scan extends Command
{
protected function configure()
{
class Scan extends Command {

/**
* @var \OC\User\Manager $userManager
*/
private $userManager;

public function __construct(\OC\User\Manager $userManager) {
$this->userManager = $userManager;
parent::__construct();
}

protected function configure() {
$this
->setName('files:scan')
->setDescription('rescan filesystem')
Expand Down Expand Up @@ -40,15 +49,17 @@ protected function scanFiles($user, OutputInterface $output) {
$scanner->scan('');
}

protected function execute(InputInterface $input, OutputInterface $output)
{
protected function execute(InputInterface $input, OutputInterface $output) {
if ($input->getOption('all')) {
$users = \OC_User::getUsers();
$users = $this->userManager->search('');
} else {
$users = $input->getArgument('user_id');
}

foreach ($users as $user) {
if (is_object($user)) {
$user = $user->getUID();
}
$this->scanFiles($user, $output);
}
}
Expand Down
2 changes: 1 addition & 1 deletion console.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
$defaults = new OC_Defaults;
$application = new Application($defaults->getName(), \OC_Util::getVersionString());
$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();

0 comments on commit cafc8cb

Please sign in to comment.