1
0

FailedCache.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\Files\Cache;
  8. use OC\Files\Search\SearchComparison;
  9. use OCP\Constants;
  10. use OCP\Files\Cache\ICache;
  11. use OCP\Files\Cache\ICacheEntry;
  12. use OCP\Files\Search\ISearchComparison;
  13. use OCP\Files\Search\ISearchOperator;
  14. use OCP\Files\Search\ISearchQuery;
  15. /**
  16. * Storage placeholder to represent a missing precondition, storage unavailable
  17. */
  18. class FailedCache implements ICache {
  19. /** @var bool whether to show the failed storage in the ui */
  20. private $visible;
  21. /**
  22. * FailedCache constructor.
  23. *
  24. * @param bool $visible
  25. */
  26. public function __construct($visible = true) {
  27. $this->visible = $visible;
  28. }
  29. public function getNumericStorageId() {
  30. return -1;
  31. }
  32. public function get($file) {
  33. if ($file === '') {
  34. return new CacheEntry([
  35. 'fileid' => -1,
  36. 'size' => 0,
  37. 'mimetype' => 'httpd/unix-directory',
  38. 'mimepart' => 'httpd',
  39. 'permissions' => $this->visible ? Constants::PERMISSION_READ : 0,
  40. 'mtime' => time()
  41. ]);
  42. } else {
  43. return false;
  44. }
  45. }
  46. public function getFolderContents($folder) {
  47. return [];
  48. }
  49. public function getFolderContentsById($fileId) {
  50. return [];
  51. }
  52. public function put($file, array $data) {
  53. }
  54. public function insert($file, array $data) {
  55. }
  56. public function update($id, array $data) {
  57. }
  58. public function getId($file) {
  59. return -1;
  60. }
  61. public function getParentId($file) {
  62. return -1;
  63. }
  64. public function inCache($file) {
  65. return false;
  66. }
  67. public function remove($file) {
  68. }
  69. public function move($source, $target) {
  70. }
  71. public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) {
  72. }
  73. public function clear() {
  74. }
  75. public function getStatus($file) {
  76. return ICache::NOT_FOUND;
  77. }
  78. public function search($pattern) {
  79. return [];
  80. }
  81. public function searchByMime($mimetype) {
  82. return [];
  83. }
  84. public function searchQuery(ISearchQuery $query) {
  85. return [];
  86. }
  87. public function getAll() {
  88. return [];
  89. }
  90. public function getIncomplete() {
  91. return [];
  92. }
  93. public function getPathById($id) {
  94. return null;
  95. }
  96. public function normalize($path) {
  97. return $path;
  98. }
  99. public function copyFromCache(ICache $sourceCache, ICacheEntry $sourceEntry, string $targetPath): int {
  100. throw new \Exception('Invalid cache');
  101. }
  102. public function getQueryFilterForStorage(): ISearchOperator {
  103. return new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', -1);
  104. }
  105. public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry {
  106. return null;
  107. }
  108. }