FailedCache.php 3.2 KB

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