IScanner.php 2.5 KB

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