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.

137 lines
2.6 KiB

3 years ago
  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 searchQuery(ISearchQuery $query) {
  96. return [];
  97. }
  98. public function getAll() {
  99. return [];
  100. }
  101. public function getIncomplete() {
  102. return [];
  103. }
  104. public function getPathById($id) {
  105. return null;
  106. }
  107. public function normalize($path) {
  108. return $path;
  109. }
  110. }