From: Bart Visscher Date: Fri, 2 Aug 2013 13:36:54 +0000 (+0200) Subject: Use console.php entry point for file scanning from console X-Git-Tag: v6.0.0alpha2~355^2~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a7a05b321afd0085bd0e8c068c95e654d229e27c;p=nextcloud-server.git Use console.php entry point for file scanning from console --- diff --git a/apps/files/console/scan.php b/apps/files/console/scan.php new file mode 100644 index 00000000000..118e586aea3 --- /dev/null +++ b/apps/files/console/scan.php @@ -0,0 +1,35 @@ +" . PHP_EOL; + echo " will rescan all files of the given user" . PHP_EOL; + echo " php scanFiles.php --all" . PHP_EOL; + echo " will rescan all files of all known users" . PHP_EOL; + return; +} + +function scanFiles($user) { + $scanner = new \OC\Files\Utils\Scanner($user); + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function($path) { + echo "Scanning $path" . PHP_EOL; + }); + $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function($path) { + echo "Scanning $path" . PHP_EOL; + }); + $scanner->scan(''); +} + +if ($argv[1] === '--all') { + $users = OC_User::getUsers(); +} else { + $users = array($argv[1]); +} + +foreach ($users as $user) { + scanFiles($user); +} diff --git a/console.php b/console.php new file mode 100644 index 00000000000..a3b1357a287 --- /dev/null +++ b/console.php @@ -0,0 +1,25 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +$RUNTIME_NOAPPS = true; +require_once 'lib/base.php'; + +// Don't do anything if ownCloud has not been installed yet +if (!OC_Config::getValue('installed', false)) { + exit(0); +} + +if (OC::$CLI) { + if ($argc > 1 && $argv[1] === 'files:scan') { + require_once 'apps/files/console/scan.php'; + } +} +else +{ + echo "This script can be run from the command line only\n"; +} diff --git a/scanFiles.php b/scanFiles.php deleted file mode 100644 index 2144fce5d5a..00000000000 --- a/scanFiles.php +++ /dev/null @@ -1,37 +0,0 @@ -" . PHP_EOL; - echo " will rescan all files of the given user" . PHP_EOL; - echo " php scanFiles.php --all" . PHP_EOL; - echo " will rescan all files of all known users" . PHP_EOL; - return; -} - -function scanFiles($user) { - $scanner = new \OC\Files\Utils\Scanner($user); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function($path) { - echo "Scanning $path" . PHP_EOL; - }); - $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function($path) { - echo "Scanning $path" . PHP_EOL; - }); - $scanner->scan(''); -} - -if ($argv[1] === '--all') { - $users = OC_User::getUsers(); -} else { - $users = array($argv[1]); -} - -foreach ($users as $user) { - scanFiles($user); -}