PageRenderTime 40ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/lib/private/Files/Storage/FailedStorage.php

https://gitlab.com/wuhang2003/core
PHP | 215 lines | 140 code | 47 blank | 28 comment | 1 complexity | a16a6fbb8faf13e2d9477c92443d91ce MD5 | raw file
  1. <?php
  2. /**
  3. * @author Robin Appelman <icewind@owncloud.com>
  4. * @author Robin McCorkell <robin@mccorkell.me.uk>
  5. *
  6. * @copyright Copyright (c) 2016, ownCloud, Inc.
  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\Storage;
  23. use OC\Files\Cache\FailedCache;
  24. use \OCP\Lock\ILockingProvider;
  25. use \OCP\Files\StorageNotAvailableException;
  26. /**
  27. * Storage placeholder to represent a missing precondition, storage unavailable
  28. */
  29. class FailedStorage extends Common {
  30. /** @var \Exception */
  31. protected $e;
  32. /**
  33. * @param array $params ['exception' => \Exception]
  34. */
  35. public function __construct($params) {
  36. $this->e = $params['exception'];
  37. if (!$this->e) {
  38. throw new \InvalidArgumentException('Missing "exception" argument in FailedStorage constructor');
  39. }
  40. }
  41. public function getId() {
  42. // we can't return anything sane here
  43. return 'failedstorage';
  44. }
  45. public function mkdir($path) {
  46. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  47. }
  48. public function rmdir($path) {
  49. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  50. }
  51. public function opendir($path) {
  52. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  53. }
  54. public function is_dir($path) {
  55. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  56. }
  57. public function is_file($path) {
  58. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  59. }
  60. public function stat($path) {
  61. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  62. }
  63. public function filetype($path) {
  64. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  65. }
  66. public function filesize($path) {
  67. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  68. }
  69. public function isCreatable($path) {
  70. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  71. }
  72. public function isReadable($path) {
  73. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  74. }
  75. public function isUpdatable($path) {
  76. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  77. }
  78. public function isDeletable($path) {
  79. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  80. }
  81. public function isSharable($path) {
  82. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  83. }
  84. public function getPermissions($path) {
  85. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  86. }
  87. public function file_exists($path) {
  88. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  89. }
  90. public function filemtime($path) {
  91. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  92. }
  93. public function file_get_contents($path) {
  94. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  95. }
  96. public function file_put_contents($path, $data) {
  97. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  98. }
  99. public function unlink($path) {
  100. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  101. }
  102. public function rename($path1, $path2) {
  103. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  104. }
  105. public function copy($path1, $path2) {
  106. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  107. }
  108. public function fopen($path, $mode) {
  109. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  110. }
  111. public function getMimeType($path) {
  112. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  113. }
  114. public function hash($type, $path, $raw = false) {
  115. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  116. }
  117. public function free_space($path) {
  118. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  119. }
  120. public function search($query) {
  121. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  122. }
  123. public function touch($path, $mtime = null) {
  124. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  125. }
  126. public function getLocalFile($path) {
  127. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  128. }
  129. public function getLocalFolder($path) {
  130. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  131. }
  132. public function hasUpdated($path, $time) {
  133. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  134. }
  135. public function getETag($path) {
  136. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  137. }
  138. public function getDirectDownload($path) {
  139. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  140. }
  141. public function verifyPath($path, $fileName) {
  142. return true;
  143. }
  144. public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
  145. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  146. }
  147. public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) {
  148. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  149. }
  150. public function acquireLock($path, $type, ILockingProvider $provider) {
  151. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  152. }
  153. public function releaseLock($path, $type, ILockingProvider $provider) {
  154. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  155. }
  156. public function changeLock($path, $type, ILockingProvider $provider) {
  157. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  158. }
  159. public function getAvailability() {
  160. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  161. }
  162. public function setAvailability($isAvailable) {
  163. throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e);
  164. }
  165. public function getCache($path = '', $storage = null) {
  166. return new FailedCache();
  167. }
  168. }