1
0

IScanner.php 2.4 KB

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