Exemple #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!$input->getOption('debug')) {
         $this->scanner->listen('\\OCA\\Music\\Utility\\Scanner', 'update', function ($path) use($output) {
             $output->writeln("Scanning <info>{$path}</info>");
         });
     }
     $inputPath = $input->getOption('path');
     $path = false;
     if ($inputPath) {
         $path = '/' . trim($inputPath, '/');
         list(, $user, ) = explode('/', $path, 3);
         $users = array($user);
     } else {
         if ($input->getOption('all')) {
             $users = $this->userManager->search('');
         } else {
             $users = $input->getArgument('user_id');
         }
     }
     foreach ($users as $user) {
         if (is_object($user)) {
             $user = $user->getUID();
         }
         \OC_Util::tearDownFS();
         \OC_Util::setupFS($user);
         $output->writeln("Start scan for <info>{$user}</info>");
         $this->scanner->rescan($user, true, $path ? $path : $this->resolveUserFolder($user), $input->getOption('debug'), $output);
     }
 }
Exemple #2
0
 /**
  * @NoAdminRequired
  */
 public function scan()
 {
     $dry = (bool) $this->params('dry');
     if ($dry) {
         $result = array('processed' => count($this->scanner->getScannedFiles($this->userId)), 'scanned' => 0, 'total' => count($this->scanner->getMusicFiles()));
     } else {
         $result = $this->scanner->rescan($this->userId);
     }
     return new JSONResponse(array($result));
 }