diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-12-10 16:17:29 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-12-10 16:17:29 +0100 |
commit | 80ae311329f56295e9ec6a4d3cee66cb9afc1a4f (patch) | |
tree | 24ca0805d06f7af4da69ecf635d77c6f40041ee1 /apps | |
parent | 3898fbc0d2d65785b8b132645c5bf99077d16818 (diff) | |
parent | 0f17486c1d6d974e25ea75597bd2ca6f50e5e538 (diff) | |
download | nextcloud-server-80ae311329f56295e9ec6a4d3cee66cb9afc1a4f.tar.gz nextcloud-server-80ae311329f56295e9ec6a4d3cee66cb9afc1a4f.zip |
Merge pull request #11892 from owncloud/remove_triggerupdate
Remove triggerupdate.php & add quiet option for CLI scanner
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/command/scan.php | 43 | ||||
-rw-r--r-- | apps/files/triggerupdate.php | 23 |
2 files changed, 32 insertions, 34 deletions
diff --git a/apps/files/command/scan.php b/apps/files/command/scan.php index 2dca0e0e67c..7cf401c7b59 100644 --- a/apps/files/command/scan.php +++ b/apps/files/command/scan.php @@ -38,6 +38,18 @@ class Scan extends Command { 'will rescan all files of the given user(s)' ) ->addOption( + 'path', + 'p', + InputArgument::OPTIONAL, + 'limit rescan to this path, eg. --path="/alice/files/Music", the user_id is determined by the path and the user_id parameter and --all are ignored' + ) + ->addOption( + 'quiet', + 'q', + InputOption::VALUE_NONE, + 'suppress output' + ) + ->addOption( 'all', null, InputOption::VALUE_NONE, @@ -45,16 +57,18 @@ class Scan extends Command { ); } - protected function scanFiles($user, OutputInterface $output) { + protected function scanFiles($user, $path, $quiet, OutputInterface $output) { $scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection()); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { - $output->writeln("Scanning <info>$path</info>"); - }); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { - $output->writeln("Scanning <info>$path</info>"); - }); + if (!$quiet) { + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { + $output->writeln("Scanning file <info>$path</info>"); + }); + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { + $output->writeln("Scanning folder <info>$path</info>"); + }); + } try { - $scanner->scan(''); + $scanner->scan($path); } catch (ForbiddenException $e) { $output->writeln("<error>Home storage for user $user not writable</error>"); $output->writeln("Make sure you're running the scan command only as the user the web server runs as"); @@ -62,14 +76,21 @@ class Scan extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { - if ($input->getOption('all')) { + $path = $input->getOption('path'); + if ($path !== false) { + $path = '/'.trim($path, '/'); + list (, $user, ) = explode('/', $path, 3); + $users = array($user); + } else if ($input->getOption('all')) { $users = $this->userManager->search(''); } else { $users = $input->getArgument('user_id'); } + $quiet = $input->getOption('quiet'); + if (count($users) === 0) { - $output->writeln("<error>Please specify the user id to scan or \"--all\" to scan for all users</error>"); + $output->writeln("<error>Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\"</error>"); return; } @@ -78,7 +99,7 @@ class Scan extends Command { $user = $user->getUID(); } if ($this->userManager->userExists($user)) { - $this->scanFiles($user, $output); + $this->scanFiles($user, $path, $quiet, $output); } else { $output->writeln("<error>Unknown user $user</error>"); } diff --git a/apps/files/triggerupdate.php b/apps/files/triggerupdate.php deleted file mode 100644 index 3f85da9913b..00000000000 --- a/apps/files/triggerupdate.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -require_once __DIR__ . '/../../lib/base.php'; - -if (OC::$CLI) { - if (count($argv) === 2) { - $file = $argv[1]; - list(, $user) = explode('/', $file); - OCP\JSON::checkUserExists($user); - OC_Util::setupFS($user); - $view = new \OC\Files\View(''); - /** - * @var \OC\Files\Storage\Storage $storage - */ - list($storage, $internalPath) = $view->resolvePath($file); - $watcher = $storage->getWatcher($internalPath); - $watcher->checkUpdate($internalPath); - } else { - echo "Usage: php triggerupdate.php /path/to/file\n"; - } -} else { - echo "This script can be run from the command line only\n"; -} |