From 7ef6df04da739af651afdcdbda6ccb095d1a90f7 Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Fri, 31 Oct 2014 17:33:33 +0100 Subject: remove triggerupdate, ref #11872 --- apps/files/command/scan.php | 14 +++++++++++--- apps/files/triggerupdate.php | 23 ----------------------- 2 files changed, 11 insertions(+), 26 deletions(-) delete mode 100644 apps/files/triggerupdate.php (limited to 'apps') diff --git a/apps/files/command/scan.php b/apps/files/command/scan.php index 2dca0e0e67c..c63a3174271 100644 --- a/apps/files/command/scan.php +++ b/apps/files/command/scan.php @@ -37,6 +37,13 @@ class Scan extends Command { InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'will rescan all files of the given user(s)' ) + ->addOption( + 'path', + null, + InputArgument::OPTIONAL, + 'limit rescan to this path, eg. --path="files/Music"', + '' + ) ->addOption( 'all', null, @@ -45,7 +52,7 @@ class Scan extends Command { ); } - protected function scanFiles($user, OutputInterface $output) { + protected function scanFiles($user, $path, 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 $path"); @@ -54,7 +61,7 @@ class Scan extends Command { $output->writeln("Scanning $path"); }); try { - $scanner->scan(''); + $scanner->scan($path); } catch (ForbiddenException $e) { $output->writeln("Home storage for user $user not writable"); $output->writeln("Make sure you're running the scan command only as the user the web server runs as"); @@ -67,6 +74,7 @@ class Scan extends Command { } else { $users = $input->getArgument('user_id'); } + $path = trim($input->getOption('path'), '/'); if (count($users) === 0) { $output->writeln("Please specify the user id to scan or \"--all\" to scan for all users"); @@ -78,7 +86,7 @@ class Scan extends Command { $user = $user->getUID(); } if ($this->userManager->userExists($user)) { - $this->scanFiles($user, $output); + $this->scanFiles($user, $path, $output); } else { $output->writeln("Unknown user $user"); } 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 @@ -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"; -} -- cgit v1.2.3 From 3cdaa4094fe7a8fa6db4885dd9a426053e845a53 Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Fri, 31 Oct 2014 17:39:05 +0100 Subject: add quiet option, ref #8794 --- apps/files/command/scan.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'apps') diff --git a/apps/files/command/scan.php b/apps/files/command/scan.php index c63a3174271..6e4b3ee4bc3 100644 --- a/apps/files/command/scan.php +++ b/apps/files/command/scan.php @@ -39,11 +39,17 @@ class Scan extends Command { ) ->addOption( 'path', - null, + 'p', InputArgument::OPTIONAL, 'limit rescan to this path, eg. --path="files/Music"', '' ) + ->addOption( + 'quiet', + 'q', + InputOption::VALUE_NONE, + 'suppress output' + ) ->addOption( 'all', null, @@ -52,14 +58,16 @@ class Scan extends Command { ); } - protected function scanFiles($user, $path, 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 $path"); - }); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { - $output->writeln("Scanning $path"); - }); + if (!$quiet) { + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { + $output->writeln("Scanning $path"); + }); + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { + $output->writeln("Scanning $path"); + }); + } try { $scanner->scan($path); } catch (ForbiddenException $e) { @@ -75,6 +83,7 @@ class Scan extends Command { $users = $input->getArgument('user_id'); } $path = trim($input->getOption('path'), '/'); + $quiet = $input->getOption('quiet'); if (count($users) === 0) { $output->writeln("Please specify the user id to scan or \"--all\" to scan for all users"); @@ -86,7 +95,7 @@ class Scan extends Command { $user = $user->getUID(); } if ($this->userManager->userExists($user)) { - $this->scanFiles($user, $path, $output); + $this->scanFiles($user, $path, $quiet, $output); } else { $output->writeln("Unknown user $user"); } -- cgit v1.2.3 From 0f17486c1d6d974e25ea75597bd2ca6f50e5e538 Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Wed, 10 Dec 2014 11:04:17 +0100 Subject: make path absolute --- apps/files/command/scan.php | 18 +++++++++++------- lib/private/files/cache/scanner.php | 6 ++++-- lib/private/files/utils/scanner.php | 3 ++- 3 files changed, 17 insertions(+), 10 deletions(-) (limited to 'apps') diff --git a/apps/files/command/scan.php b/apps/files/command/scan.php index 6e4b3ee4bc3..7cf401c7b59 100644 --- a/apps/files/command/scan.php +++ b/apps/files/command/scan.php @@ -41,8 +41,7 @@ class Scan extends Command { 'path', 'p', InputArgument::OPTIONAL, - 'limit rescan to this path, eg. --path="files/Music"', - '' + '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', @@ -62,10 +61,10 @@ class Scan extends Command { $scanner = new \OC\Files\Utils\Scanner($user, \OC::$server->getDatabaseConnection()); if (!$quiet) { $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function ($path) use ($output) { - $output->writeln("Scanning $path"); + $output->writeln("Scanning file $path"); }); $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function ($path) use ($output) { - $output->writeln("Scanning $path"); + $output->writeln("Scanning folder $path"); }); } try { @@ -77,16 +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'); } - $path = trim($input->getOption('path'), '/'); $quiet = $input->getOption('quiet'); + if (count($users) === 0) { - $output->writeln("Please specify the user id to scan or \"--all\" to scan for all users"); + $output->writeln("Please specify the user id to scan, \"--all\" to scan for all users or \"--path=...\""); return; } diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php index 444207518b2..a5383cee10d 100644 --- a/lib/private/files/cache/scanner.php +++ b/lib/private/files/cache/scanner.php @@ -219,8 +219,10 @@ class Scanner extends BasicEmitter { $reuse = ($recursive === self::SCAN_SHALLOW) ? self::REUSE_ETAG | self::REUSE_SIZE : 0; } $data = $this->scanFile($path, $reuse); - $size = $this->scanChildren($path, $recursive, $reuse); - $data['size'] = $size; + if ($data !== null) { + $size = $this->scanChildren($path, $recursive, $reuse); + $data['size'] = $size; + } return $data; } diff --git a/lib/private/files/utils/scanner.php b/lib/private/files/utils/scanner.php index a0b06328579..7625e52e015 100644 --- a/lib/private/files/utils/scanner.php +++ b/lib/private/files/utils/scanner.php @@ -127,11 +127,12 @@ class Scanner extends PublicEmitter { ) { throw new ForbiddenException(); } + $relativePath = $mount->getInternalPath($dir); $scanner = $storage->getScanner(); $scanner->setUseTransactions(false); $this->attachListener($mount); $this->db->beginTransaction(); - $scanner->scan($dir, \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE); + $scanner->scan($relativePath, \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE); $this->db->commit(); } $this->propagator->propagateChanges(time()); -- cgit v1.2.3