failedcache.php 2.7 KB

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