You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.6 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Robin Appelman <robin@icewind.nl>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCP\Files\Cache;
  24. /**
  25. * Scan files from the storage and save to the cache
  26. *
  27. * @since 9.0.0
  28. */
  29. interface IScanner {
  30. public const SCAN_RECURSIVE_INCOMPLETE = 2; // only recursive into not fully scanned folders
  31. public const SCAN_RECURSIVE = true;
  32. public const SCAN_SHALLOW = false;
  33. public const REUSE_NONE = 0;
  34. public const REUSE_ETAG = 1;
  35. public const REUSE_SIZE = 2;
  36. /**
  37. * scan a single file and store it in the cache
  38. *
  39. * @param string $file
  40. * @param int $reuseExisting
  41. * @param int $parentId
  42. * @param array | null $cacheData existing data in the cache for the file to be scanned
  43. * @param bool $lock set to false to disable getting an additional read lock during scanning
  44. * @return array an array of metadata of the scanned file
  45. * @throws \OC\ServerNotAvailableException
  46. * @throws \OCP\Lock\LockedException
  47. * @since 9.0.0
  48. */
  49. public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true);
  50. /**
  51. * scan a folder and all its children
  52. *
  53. * @param string $path
  54. * @param bool $recursive
  55. * @param int $reuse
  56. * @param bool $lock set to false to disable getting an additional read lock during scanning
  57. * @return array an array of the meta data of the scanned file or folder
  58. * @since 9.0.0
  59. */
  60. public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true);
  61. /**
  62. * check if the file should be ignored when scanning
  63. * NOTE: files with a '.part' extension are ignored as well!
  64. * prevents unfinished put requests to be scanned
  65. *
  66. * @param string $file
  67. * @return boolean
  68. * @since 9.0.0
  69. */
  70. public static function isPartialFile($file);
  71. /**
  72. * walk over any folders that are not fully scanned yet and scan them
  73. *
  74. * @since 9.0.0
  75. */
  76. public function backgroundScan();
  77. }