scan.php 751 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. if (count($argv) !== 2) {
  3. echo "Usage:" . PHP_EOL;
  4. echo " files:scan <user_id>" . PHP_EOL;
  5. echo " will rescan all files of the given user" . PHP_EOL;
  6. echo " files:scan --all" . PHP_EOL;
  7. echo " will rescan all files of all known users" . PHP_EOL;
  8. return;
  9. }
  10. function scanFiles($user) {
  11. $scanner = new \OC\Files\Utils\Scanner($user);
  12. $scanner->listen('\OC\Files\Utils\Scanner', 'scanFile', function($path) {
  13. echo "Scanning $path" . PHP_EOL;
  14. });
  15. $scanner->listen('\OC\Files\Utils\Scanner', 'scanFolder', function($path) {
  16. echo "Scanning $path" . PHP_EOL;
  17. });
  18. $scanner->scan('');
  19. }
  20. if ($argv[1] === '--all') {
  21. $users = OC_User::getUsers();
  22. } else {
  23. $users = array($argv[1]);
  24. }
  25. foreach ($users as $user) {
  26. scanFiles($user);
  27. }