NullCache.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OC\Lockdown\Filesystem;
  7. use OC\Files\Cache\CacheEntry;
  8. use OC\Files\Search\SearchComparison;
  9. use OCP\Constants;
  10. use OCP\Files\Cache\ICache;
  11. use OCP\Files\Cache\ICacheEntry;
  12. use OCP\Files\FileInfo;
  13. use OCP\Files\Search\ISearchComparison;
  14. use OCP\Files\Search\ISearchOperator;
  15. use OCP\Files\Search\ISearchQuery;
  16. class NullCache implements ICache {
  17. public function getNumericStorageId() {
  18. return -1;
  19. }
  20. public function get($file) {
  21. return $file !== '' ? null :
  22. new CacheEntry([
  23. 'fileid' => -1,
  24. 'parent' => -1,
  25. 'name' => '',
  26. 'path' => '',
  27. 'size' => '0',
  28. 'mtime' => time(),
  29. 'storage_mtime' => time(),
  30. 'etag' => '',
  31. 'mimetype' => FileInfo::MIMETYPE_FOLDER,
  32. 'mimepart' => 'httpd',
  33. 'permissions' => Constants::PERMISSION_READ
  34. ]);
  35. }
  36. public function getFolderContents($folder) {
  37. return [];
  38. }
  39. public function getFolderContentsById($fileId) {
  40. return [];
  41. }
  42. public function put($file, array $data) {
  43. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  44. }
  45. public function insert($file, array $data) {
  46. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  47. }
  48. public function update($id, array $data) {
  49. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  50. }
  51. public function getId($file) {
  52. return -1;
  53. }
  54. public function getParentId($file) {
  55. return -1;
  56. }
  57. public function inCache($file) {
  58. return $file === '';
  59. }
  60. public function remove($file) {
  61. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  62. }
  63. public function move($source, $target) {
  64. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  65. }
  66. public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
  67. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  68. }
  69. public function getStatus($file) {
  70. return ICache::COMPLETE;
  71. }
  72. public function search($pattern) {
  73. return [];
  74. }
  75. public function searchByMime($mimetype) {
  76. return [];
  77. }
  78. public function searchQuery(ISearchQuery $query) {
  79. return [];
  80. }
  81. public function getIncomplete() {
  82. return [];
  83. }
  84. public function getPathById($id) {
  85. return '';
  86. }
  87. public function normalize($path) {
  88. return $path;
  89. }
  90. public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int {
  91. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  92. }
  93. public function getQueryFilterForStorage(): ISearchOperator {
  94. return new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', -1);
  95. }
  96. public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry {
  97. return null;
  98. }
  99. }