1
0

FailedCache.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. }
  65. public function insert($file, array $data) {
  66. }
  67. public function update($id, array $data) {
  68. }
  69. public function getId($file) {
  70. return -1;
  71. }
  72. public function getParentId($file) {
  73. return -1;
  74. }
  75. public function inCache($file) {
  76. return false;
  77. }
  78. public function remove($file) {
  79. }
  80. public function move($source, $target) {
  81. }
  82. public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
  83. }
  84. public function clear() {
  85. }
  86. public function getStatus($file) {
  87. return ICache::NOT_FOUND;
  88. }
  89. public function search($pattern) {
  90. return [];
  91. }
  92. public function searchByMime($mimetype) {
  93. return [];
  94. }
  95. public function searchByTag($tag, $userId) {
  96. return [];
  97. }
  98. public function searchQuery(ISearchQuery $query) {
  99. return [];
  100. }
  101. public function getAll() {
  102. return [];
  103. }
  104. public function getIncomplete() {
  105. return [];
  106. }
  107. public function getPathById($id) {
  108. return null;
  109. }
  110. public function normalize($path) {
  111. return $path;
  112. }
  113. }