FailedCache.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 OC\Files\Cache;
  23. use OCP\Constants;
  24. use OCP\Files\Cache\ICache;
  25. use OCP\Files\Search\ISearchQuery;
  26. /**
  27. * Storage placeholder to represent a missing precondition, storage unavailable
  28. */
  29. class FailedCache implements ICache {
  30. /** @var bool whether to show the failed storage in the ui */
  31. private $visible;
  32. /**
  33. * FailedCache constructor.
  34. *
  35. * @param bool $visible
  36. */
  37. public function __construct($visible = true) {
  38. $this->visible = $visible;
  39. }
  40. public function getNumericStorageId() {
  41. return -1;
  42. }
  43. public function get($file) {
  44. if ($file === '') {
  45. return new CacheEntry([
  46. 'fileid' => -1,
  47. 'size' => 0,
  48. 'mimetype' => 'httpd/unix-directory',
  49. 'mimepart' => 'httpd',
  50. 'permissions' => $this->visible ? Constants::PERMISSION_READ : 0,
  51. 'mtime' => time()
  52. ]);
  53. } else {
  54. return false;
  55. }
  56. }
  57. public function getFolderContents($folder) {
  58. return [];
  59. }
  60. public function getFolderContentsById($fileId) {
  61. return [];
  62. }
  63. public function put($file, array $data) {
  64. return;
  65. }
  66. public function insert($file, array $data) {
  67. return;
  68. }
  69. public function update($id, array $data) {
  70. return;
  71. }
  72. public function getId($file) {
  73. return -1;
  74. }
  75. public function getParentId($file) {
  76. return -1;
  77. }
  78. public function inCache($file) {
  79. return false;
  80. }
  81. public function remove($file) {
  82. return;
  83. }
  84. public function move($source, $target) {
  85. return;
  86. }
  87. public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
  88. return;
  89. }
  90. public function clear() {
  91. return;
  92. }
  93. public function getStatus($file) {
  94. return ICache::NOT_FOUND;
  95. }
  96. public function search($pattern) {
  97. return [];
  98. }
  99. public function searchByMime($mimetype) {
  100. return [];
  101. }
  102. public function searchByTag($tag, $userId) {
  103. return [];
  104. }
  105. public function searchQuery(ISearchQuery $query) {
  106. return [];
  107. }
  108. public function getAll() {
  109. return [];
  110. }
  111. public function getIncomplete() {
  112. return [];
  113. }
  114. public function getPathById($id) {
  115. return null;
  116. }
  117. public function normalize($path) {
  118. return $path;
  119. }
  120. }