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.

125 lines
3.0 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, Robin Appelman <robin@icewind.nl>
  4. *
  5. * @author Robin Appelman <robin@icewind.nl>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  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
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OC\Lockdown\Filesystem;
  24. use OC\Files\Cache\CacheEntry;
  25. use OCP\Constants;
  26. use OCP\Files\Cache\ICache;
  27. use OCP\Files\FileInfo;
  28. use OCP\Files\Search\ISearchQuery;
  29. class NullCache implements ICache {
  30. public function getNumericStorageId() {
  31. return -1;
  32. }
  33. public function get($file) {
  34. return $file !== '' ? null :
  35. new CacheEntry([
  36. 'fileid' => -1,
  37. 'parent' => -1,
  38. 'name' => '',
  39. 'path' => '',
  40. 'size' => '0',
  41. 'mtime' => time(),
  42. 'storage_mtime' => time(),
  43. 'etag' => '',
  44. 'mimetype' => FileInfo::MIMETYPE_FOLDER,
  45. 'mimepart' => 'httpd',
  46. 'permissions' => Constants::PERMISSION_READ
  47. ]);
  48. }
  49. public function getFolderContents($folder) {
  50. return [];
  51. }
  52. public function getFolderContentsById($fileId) {
  53. return [];
  54. }
  55. public function put($file, array $data) {
  56. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  57. }
  58. public function insert($file, array $data) {
  59. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  60. }
  61. public function update($id, array $data) {
  62. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  63. }
  64. public function getId($file) {
  65. return -1;
  66. }
  67. public function getParentId($file) {
  68. return -1;
  69. }
  70. public function inCache($file) {
  71. return $file === '';
  72. }
  73. public function remove($file) {
  74. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  75. }
  76. public function move($source, $target) {
  77. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  78. }
  79. public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
  80. throw new \OC\ForbiddenException('This request is not allowed to access the filesystem');
  81. }
  82. public function getStatus($file) {
  83. return ICache::COMPLETE;
  84. }
  85. public function search($pattern) {
  86. return [];
  87. }
  88. public function searchByMime($mimetype) {
  89. return [];
  90. }
  91. public function searchQuery(ISearchQuery $query) {
  92. return [];
  93. }
  94. public function getIncomplete() {
  95. return [];
  96. }
  97. public function getPathById($id) {
  98. return '';
  99. }
  100. public function normalize($path) {
  101. return $path;
  102. }
  103. }