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.

126 lines
2.9 KiB

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