1
0

IScanner.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\Files\Cache;
  8. /**
  9. * Scan files from the storage and save to the cache
  10. *
  11. * @since 9.0.0
  12. */
  13. interface IScanner {
  14. /**
  15. * @since 9.0.0
  16. */
  17. public const SCAN_RECURSIVE_INCOMPLETE = 2; // only recursive into not fully scanned folders
  18. /**
  19. * @since 9.0.0
  20. */
  21. public const SCAN_RECURSIVE = true;
  22. /**
  23. * @since 9.0.0
  24. */
  25. public const SCAN_SHALLOW = false;
  26. /**
  27. * @since 12.0.0
  28. */
  29. public const REUSE_NONE = 0;
  30. /**
  31. * @since 9.0.0
  32. */
  33. public const REUSE_ETAG = 1;
  34. /**
  35. * @since 9.0.0
  36. */
  37. public const REUSE_SIZE = 2;
  38. /**
  39. * scan a single file and store it in the cache
  40. *
  41. * @param string $file
  42. * @param int $reuseExisting
  43. * @param int $parentId
  44. * @param array | null $cacheData existing data in the cache for the file to be scanned
  45. * @param bool $lock set to false to disable getting an additional read lock during scanning
  46. * @return array | null an array of metadata of the scanned file
  47. * @throws \OC\ServerNotAvailableException
  48. * @throws \OCP\Lock\LockedException
  49. * @since 9.0.0
  50. */
  51. public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true);
  52. /**
  53. * scan a folder and all its children
  54. *
  55. * @param string $path
  56. * @param bool $recursive
  57. * @param int $reuse
  58. * @param bool $lock set to false to disable getting an additional read lock during scanning
  59. * @return array | null an array of the meta data of the scanned file or folder
  60. * @since 9.0.0
  61. */
  62. public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true);
  63. /**
  64. * check if the file should be ignored when scanning
  65. * NOTE: files with a '.part' extension are ignored as well!
  66. * prevents unfinished put requests to be scanned
  67. *
  68. * @param string $file
  69. * @return boolean
  70. * @since 9.0.0
  71. */
  72. public static function isPartialFile($file);
  73. /**
  74. * walk over any folders that are not fully scanned yet and scan them
  75. *
  76. * @since 9.0.0
  77. */
  78. public function backgroundScan();
  79. }