IScanner.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. /**
  31. * @since 9.0.0
  32. */
  33. public const SCAN_RECURSIVE_INCOMPLETE = 2; // only recursive into not fully scanned folders
  34. /**
  35. * @since 9.0.0
  36. */
  37. public const SCAN_RECURSIVE = true;
  38. /**
  39. * @since 9.0.0
  40. */
  41. public const SCAN_SHALLOW = false;
  42. /**
  43. * @since 12.0.0
  44. */
  45. public const REUSE_NONE = 0;
  46. /**
  47. * @since 9.0.0
  48. */
  49. public const REUSE_ETAG = 1;
  50. /**
  51. * @since 9.0.0
  52. */
  53. public const REUSE_SIZE = 2;
  54. /**
  55. * scan a single file and store it in the cache
  56. *
  57. * @param string $file
  58. * @param int $reuseExisting
  59. * @param int $parentId
  60. * @param array | null $cacheData existing data in the cache for the file to be scanned
  61. * @param bool $lock set to false to disable getting an additional read lock during scanning
  62. * @return array | null an array of metadata of the scanned file
  63. * @throws \OC\ServerNotAvailableException
  64. * @throws \OCP\Lock\LockedException
  65. * @since 9.0.0
  66. */
  67. public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData = null, $lock = true);
  68. /**
  69. * scan a folder and all its children
  70. *
  71. * @param string $path
  72. * @param bool $recursive
  73. * @param int $reuse
  74. * @param bool $lock set to false to disable getting an additional read lock during scanning
  75. * @return array | null an array of the meta data of the scanned file or folder
  76. * @since 9.0.0
  77. */
  78. public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true);
  79. /**
  80. * check if the file should be ignored when scanning
  81. * NOTE: files with a '.part' extension are ignored as well!
  82. * prevents unfinished put requests to be scanned
  83. *
  84. * @param string $file
  85. * @return boolean
  86. * @since 9.0.0
  87. */
  88. public static function isPartialFile($file);
  89. /**
  90. * walk over any folders that are not fully scanned yet and scan them
  91. *
  92. * @since 9.0.0
  93. */
  94. public function backgroundScan();
  95. }