LocalRootScanner.php 925 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Files\Cache;
  8. class LocalRootScanner extends Scanner {
  9. public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true, $data = null) {
  10. if ($this->shouldScanPath($file)) {
  11. return parent::scanFile($file, $reuseExisting, $parentId, $cacheData, $lock, $data);
  12. } else {
  13. return null;
  14. }
  15. }
  16. public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true) {
  17. if ($this->shouldScanPath($path)) {
  18. return parent::scan($path, $recursive, $reuse, $lock);
  19. } else {
  20. return null;
  21. }
  22. }
  23. private function shouldScanPath(string $path): bool {
  24. $path = trim($path, '/');
  25. return $path === '' || str_starts_with($path, 'appdata_') || str_starts_with($path, '__groupfolders');
  26. }
  27. }