failedstorage.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <?php
  2. /**
  3. * @author Robin McCorkell <robin@mccorkell.me.uk>
  4. *
  5. * @copyright Copyright (c) 2016, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace OCA\Files_External\Lib;
  22. use \OCP\Lock\ILockingProvider;
  23. use \OC\Files\Storage\Common;
  24. use \OCP\Files\StorageNotAvailableException;
  25. /**
  26. * Storage placeholder to represent a missing precondition, storage unavailable
  27. */
  28. class FailedStorage extends Common {
  29. /** @var \Exception */
  30. protected $e;
  31. /**
  32. * @param array $params ['exception' => \Exception]
  33. */
  34. public function __construct($params) {
  35. $this->e = $params['exception'];
  36. }
  37. public function getId() {
  38. // we can't return anything sane here
  39. return 'failedstorage';
  40. }
  41. public function mkdir($path) {
  42. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  43. }
  44. public function rmdir($path) {
  45. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  46. }
  47. public function opendir($path) {
  48. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  49. }
  50. public function is_dir($path) {
  51. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  52. }
  53. public function is_file($path) {
  54. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  55. }
  56. public function stat($path) {
  57. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  58. }
  59. public function filetype($path) {
  60. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  61. }
  62. public function filesize($path) {
  63. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  64. }
  65. public function isCreatable($path) {
  66. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  67. }
  68. public function isReadable($path) {
  69. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  70. }
  71. public function isUpdatable($path) {
  72. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  73. }
  74. public function isDeletable($path) {
  75. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  76. }
  77. public function isSharable($path) {
  78. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  79. }
  80. public function getPermissions($path) {
  81. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  82. }
  83. public function file_exists($path) {
  84. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  85. }
  86. public function filemtime($path) {
  87. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  88. }
  89. public function file_get_contents($path) {
  90. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  91. }
  92. public function file_put_contents($path, $data) {
  93. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  94. }
  95. public function unlink($path) {
  96. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  97. }
  98. public function rename($path1, $path2) {
  99. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  100. }
  101. public function copy($path1, $path2) {
  102. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  103. }
  104. public function fopen($path, $mode) {
  105. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  106. }
  107. public function getMimeType($path) {
  108. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  109. }
  110. public function hash($type, $path, $raw = false) {
  111. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  112. }
  113. public function free_space($path) {
  114. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  115. }
  116. public function search($query) {
  117. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  118. }
  119. public function touch($path, $mtime = null) {
  120. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  121. }
  122. public function getLocalFile($path) {
  123. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  124. }
  125. public function getLocalFolder($path) {
  126. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  127. }
  128. public function hasUpdated($path, $time) {
  129. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  130. }
  131. public function getETag($path) {
  132. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  133. }
  134. public function getDirectDownload($path) {
  135. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  136. }
  137. public function verifyPath($path, $fileName) {
  138. return true;
  139. }
  140. public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
  141. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  142. }
  143. public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
  144. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  145. }
  146. public function acquireLock($path, $type, ILockingProvider $provider) {
  147. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  148. }
  149. public function releaseLock($path, $type, ILockingProvider $provider) {
  150. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  151. }
  152. public function changeLock($path, $type, ILockingProvider $provider) {
  153. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  154. }
  155. public function getAvailability() {
  156. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  157. }
  158. public function setAvailability($isAvailable) {
  159. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  160. }
  161. public function getCache($path = '', $storage = null) {
  162. return new FailedCache();
  163. }
  164. }