diff options
author | Robin Appelman <icewind@owncloud.com> | 2016-03-10 13:38:48 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-03-11 13:15:45 +0100 |
commit | a8db587b1f036bba917288372405d8d830faee54 (patch) | |
tree | 58de6a57d46dbfcb82feaec1a07efb541c6dd06a /apps | |
parent | 3bd6fc797dd5635f3881f303f3b475af636373a7 (diff) | |
download | nextcloud-server-a8db587b1f036bba917288372405d8d830faee54.tar.gz nextcloud-server-a8db587b1f036bba917288372405d8d830faee54.zip |
move failedstorage to core
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_external/lib/config/configadapter.php | 2 | ||||
-rw-r--r-- | apps/files_external/lib/failedcache.php | 142 | ||||
-rw-r--r-- | apps/files_external/lib/failedstorage.php | 215 | ||||
-rw-r--r-- | apps/files_sharing/lib/sharedstorage.php | 2 |
4 files changed, 2 insertions, 359 deletions
diff --git a/apps/files_external/lib/config/configadapter.php b/apps/files_external/lib/config/configadapter.php index d85e0f45631..a19a111d3d9 100644 --- a/apps/files_external/lib/config/configadapter.php +++ b/apps/files_external/lib/config/configadapter.php @@ -34,7 +34,7 @@ use OCP\IUser; use OCA\Files_external\Service\UserStoragesService; use OCA\Files_External\Service\UserGlobalStoragesService; use OCA\Files_External\Lib\StorageConfig; -use OCA\Files_External\Lib\FailedStorage; +use OC\Files\Storage\FailedStorage; use OCP\Files\StorageNotAvailableException; /** diff --git a/apps/files_external/lib/failedcache.php b/apps/files_external/lib/failedcache.php deleted file mode 100644 index 2fddb3eca89..00000000000 --- a/apps/files_external/lib/failedcache.php +++ /dev/null @@ -1,142 +0,0 @@ -<?php -/** - * @author Robin Appelman <icewind@owncloud.com> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OCA\Files_External\Lib; - -use OC\Files\Cache\CacheEntry; -use OCP\Constants; -use OCP\Files\Cache\ICache; - -/** - * Storage placeholder to represent a missing precondition, storage unavailable - */ -class FailedCache implements ICache { - private $visible; - - /** - * FailedCache constructor. - * - * @param bool $visible - */ - public function __construct($visible = true) { - $this->visible = $visible; - } - - - public function getNumericStorageId() { - return -1; - } - - public function get($file) { - if ($file === '') { - return new CacheEntry([ - 'fileid' => -1, - 'size' => 0, - 'mimetype' => 'httpd/unix-directory', - 'mimepart' => 'httpd', - 'permissions' => $this->visible ? Constants::PERMISSION_READ : 0, - 'mtime' => time() - ]); - } else { - return false; - } - } - - public function getFolderContents($folder) { - return []; - } - - public function getFolderContentsById($fileId) { - return []; - } - - public function put($file, array $data) { - return; - } - - public function insert($file, array $data) { - return; - } - - public function update($id, array $data) { - return; - } - - public function getId($file) { - return -1; - } - - public function getParentId($file) { - return -1; - } - - public function inCache($file) { - return false; - } - - public function remove($file) { - return; - } - - public function move($source, $target) { - return; - } - - public function moveFromCache(ICache $sourceCache, $sourcePath, $targetPath) { - return; - } - - public function clear() { - return; - } - - public function getStatus($file) { - return ICache::NOT_FOUND; - } - - public function search($pattern) { - return []; - } - - public function searchByMime($mimetype) { - return []; - } - - public function searchByTag($tag, $userId) { - return []; - } - - public function getAll() { - return []; - } - - public function getIncomplete() { - return []; - } - - public function getPathById($id) { - return null; - } - - public function normalize($path) { - return $path; - } -} diff --git a/apps/files_external/lib/failedstorage.php b/apps/files_external/lib/failedstorage.php deleted file mode 100644 index 20cf43d74b2..00000000000 --- a/apps/files_external/lib/failedstorage.php +++ /dev/null @@ -1,215 +0,0 @@ -<?php -/** - * @author Robin Appelman <icewind@owncloud.com> - * @author Robin McCorkell <robin@mccorkell.me.uk> - * - * @copyright Copyright (c) 2016, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OCA\Files_External\Lib; - -use \OCP\Lock\ILockingProvider; -use \OC\Files\Storage\Common; -use \OCP\Files\StorageNotAvailableException; - -/** - * Storage placeholder to represent a missing precondition, storage unavailable - */ -class FailedStorage extends Common { - - /** @var \Exception */ - protected $e; - - /** - * @param array $params ['exception' => \Exception] - */ - public function __construct($params) { - $this->e = $params['exception']; - if (!$this->e) { - throw new \InvalidArgumentException('Missing "exception" argument in FailedStorage constructor'); - } - } - - public function getId() { - // we can't return anything sane here - return 'failedstorage'; - } - - public function mkdir($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function rmdir($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function opendir($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function is_dir($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function is_file($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function stat($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function filetype($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function filesize($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function isCreatable($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function isReadable($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function isUpdatable($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function isDeletable($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function isSharable($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function getPermissions($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function file_exists($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function filemtime($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function file_get_contents($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function file_put_contents($path, $data) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function unlink($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function rename($path1, $path2) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function copy($path1, $path2) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function fopen($path, $mode) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function getMimeType($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function hash($type, $path, $raw = false) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function free_space($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function search($query) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function touch($path, $mtime = null) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function getLocalFile($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function getLocalFolder($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function hasUpdated($path, $time) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function getETag($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function getDirectDownload($path) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function verifyPath($path, $fileName) { - return true; - } - - public function copyFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function acquireLock($path, $type, ILockingProvider $provider) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function releaseLock($path, $type, ILockingProvider $provider) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function changeLock($path, $type, ILockingProvider $provider) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function getAvailability() { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function setAvailability($isAvailable) { - throw new StorageNotAvailableException($this->e->getMessage(), $this->e->getCode(), $this->e); - } - - public function getCache($path = '', $storage = null) { - return new FailedCache(); - } -} diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 6257320ca4e..8f4888d20e2 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -31,7 +31,7 @@ namespace OC\Files\Storage; use OC\Files\Filesystem; -use OCA\Files_External\Lib\FailedCache; +use OC\Files\Cache\FailedCache; use OCA\Files_Sharing\ISharedStorage; use OCP\Constants; use OCP\Files\Cache\ICacheEntry; |