mirror of
https://github.com/nextcloud/server.git
synced 2026-04-22 23:03:00 -04:00
Merge pull request #48614 from nextcloud/refactor/storage/constructors
This commit is contained in:
commit
5efb175665
34 changed files with 166 additions and 167 deletions
|
|
@ -15,14 +15,14 @@ class PublicOwnerWrapper extends Wrapper {
|
|||
private string $owner;
|
||||
|
||||
/**
|
||||
* @param array $arguments ['storage' => $storage, 'owner' => $owner]
|
||||
* @param array $parameters ['storage' => $storage, 'owner' => $owner]
|
||||
*
|
||||
* $storage: The storage the permissions mask should be applied on
|
||||
* $owner: The owner to use in case no owner is found
|
||||
*/
|
||||
public function __construct($arguments) {
|
||||
parent::__construct($arguments);
|
||||
$this->owner = $arguments['owner'];
|
||||
public function __construct(array $parameters) {
|
||||
parent::__construct($parameters);
|
||||
$this->owner = $parameters['owner'];
|
||||
}
|
||||
|
||||
public function getOwner(string $path): string|false {
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ class PublicShareWrapper extends Wrapper implements ISharedStorage {
|
|||
private IShare $share;
|
||||
|
||||
/**
|
||||
* @param array $arguments ['storage' => $storage, 'share' => $share]
|
||||
* @param array $parameters ['storage' => $storage, 'share' => $share]
|
||||
*
|
||||
* $storage: The storage the permissions mask should be applied on
|
||||
* $share: The share to use in case no share is found
|
||||
*/
|
||||
public function __construct($arguments) {
|
||||
parent::__construct($arguments);
|
||||
$this->share = $arguments['share'];
|
||||
public function __construct(array $parameters) {
|
||||
parent::__construct($parameters);
|
||||
$this->share = $parameters['share'];
|
||||
}
|
||||
|
||||
public function getShare(): IShare {
|
||||
|
|
|
|||
|
|
@ -13,13 +13,12 @@ use OCP\Constants;
|
|||
* Wrap Storage in PermissionsMask for session ephemeral use
|
||||
*/
|
||||
class SessionStorageWrapper extends PermissionsMask {
|
||||
|
||||
/**
|
||||
* @param array $arguments ['storage' => $storage]
|
||||
* @param array $parameters ['storage' => $storage]
|
||||
*/
|
||||
public function __construct($arguments) {
|
||||
public function __construct(array $parameters) {
|
||||
// disable sharing permission
|
||||
$arguments['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE;
|
||||
parent::__construct($arguments);
|
||||
$parameters['mask'] = Constants::PERMISSION_ALL & ~Constants::PERMISSION_SHARE;
|
||||
parent::__construct($parameters);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class AmazonS3 extends Common {
|
|||
private ?bool $versioningEnabled = null;
|
||||
private ICache $memCache;
|
||||
|
||||
public function __construct($parameters) {
|
||||
public function __construct(array $parameters) {
|
||||
parent::__construct($parameters);
|
||||
$this->parseParams($parameters);
|
||||
$this->id = 'amazon::external::' . md5($this->params['hostname'] . ':' . $this->params['bucket'] . ':' . $this->params['key']);
|
||||
|
|
|
|||
|
|
@ -29,23 +29,23 @@ class FTP extends Common {
|
|||
/** @var FtpConnection|null */
|
||||
private $connection;
|
||||
|
||||
public function __construct($params) {
|
||||
if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
|
||||
$this->host = $params['host'];
|
||||
$this->username = $params['user'];
|
||||
$this->password = $params['password'];
|
||||
if (isset($params['secure'])) {
|
||||
if (is_string($params['secure'])) {
|
||||
$this->secure = ($params['secure'] === 'true');
|
||||
public function __construct(array $parameters) {
|
||||
if (isset($parameters['host']) && isset($parameters['user']) && isset($parameters['password'])) {
|
||||
$this->host = $parameters['host'];
|
||||
$this->username = $parameters['user'];
|
||||
$this->password = $parameters['password'];
|
||||
if (isset($parameters['secure'])) {
|
||||
if (is_string($parameters['secure'])) {
|
||||
$this->secure = ($parameters['secure'] === 'true');
|
||||
} else {
|
||||
$this->secure = (bool)$params['secure'];
|
||||
$this->secure = (bool)$parameters['secure'];
|
||||
}
|
||||
} else {
|
||||
$this->secure = false;
|
||||
}
|
||||
$this->root = isset($params['root']) ? '/' . ltrim($params['root']) : '/';
|
||||
$this->port = $params['port'] ?? 21;
|
||||
$this->utf8Mode = isset($params['utf8']) && $params['utf8'];
|
||||
$this->root = isset($parameters['root']) ? '/' . ltrim($parameters['root']) : '/';
|
||||
$this->port = $parameters['port'] ?? 21;
|
||||
$this->utf8Mode = isset($parameters['utf8']) && $parameters['utf8'];
|
||||
} else {
|
||||
throw new \Exception('Creating ' . self::class . ' storage failed, required parameters not set');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,17 +20,17 @@ use Sabre\DAV\Client;
|
|||
class OwnCloud extends DAV implements IDisableEncryptionStorage {
|
||||
public const OC_URL_SUFFIX = 'remote.php/webdav';
|
||||
|
||||
public function __construct($params) {
|
||||
public function __construct(array $parameters) {
|
||||
// extract context path from host if specified
|
||||
// (owncloud install path on host)
|
||||
$host = $params['host'];
|
||||
$host = $parameters['host'];
|
||||
// strip protocol
|
||||
if (substr($host, 0, 8) === 'https://') {
|
||||
$host = substr($host, 8);
|
||||
$params['secure'] = true;
|
||||
$parameters['secure'] = true;
|
||||
} elseif (substr($host, 0, 7) === 'http://') {
|
||||
$host = substr($host, 7);
|
||||
$params['secure'] = false;
|
||||
$parameters['secure'] = false;
|
||||
}
|
||||
$contextPath = '';
|
||||
$hostSlashPos = strpos($host, '/');
|
||||
|
|
@ -43,17 +43,17 @@ class OwnCloud extends DAV implements IDisableEncryptionStorage {
|
|||
$contextPath .= '/';
|
||||
}
|
||||
|
||||
if (isset($params['root'])) {
|
||||
$root = '/' . ltrim($params['root'], '/');
|
||||
if (isset($parameters['root'])) {
|
||||
$root = '/' . ltrim($parameters['root'], '/');
|
||||
} else {
|
||||
$root = '/';
|
||||
}
|
||||
|
||||
$params['host'] = $host;
|
||||
$params['root'] = $contextPath . self::OC_URL_SUFFIX . $root;
|
||||
$params['authType'] = Client::AUTH_BASIC;
|
||||
$parameters['host'] = $host;
|
||||
$parameters['root'] = $contextPath . self::OC_URL_SUFFIX . $root;
|
||||
$parameters['authType'] = Client::AUTH_BASIC;
|
||||
|
||||
parent::__construct($params);
|
||||
parent::__construct($parameters);
|
||||
}
|
||||
|
||||
public function needsPartFile(): bool {
|
||||
|
|
|
|||
|
|
@ -57,25 +57,25 @@ class SFTP extends Common {
|
|||
}
|
||||
}
|
||||
|
||||
public function __construct($params) {
|
||||
public function __construct(array $parameters) {
|
||||
// Register sftp://
|
||||
Stream::register();
|
||||
|
||||
$parsedHost = $this->splitHost($params['host']);
|
||||
$parsedHost = $this->splitHost($parameters['host']);
|
||||
|
||||
$this->host = $parsedHost[0];
|
||||
$this->port = $parsedHost[1];
|
||||
|
||||
if (!isset($params['user'])) {
|
||||
if (!isset($parameters['user'])) {
|
||||
throw new \UnexpectedValueException('no authentication parameters specified');
|
||||
}
|
||||
$this->user = $params['user'];
|
||||
$this->user = $parameters['user'];
|
||||
|
||||
if (isset($params['public_key_auth'])) {
|
||||
$this->auth[] = $params['public_key_auth'];
|
||||
if (isset($parameters['public_key_auth'])) {
|
||||
$this->auth[] = $parameters['public_key_auth'];
|
||||
}
|
||||
if (isset($params['password']) && $params['password'] !== '') {
|
||||
$this->auth[] = $params['password'];
|
||||
if (isset($parameters['password']) && $parameters['password'] !== '') {
|
||||
$this->auth[] = $parameters['password'];
|
||||
}
|
||||
|
||||
if ($this->auth === []) {
|
||||
|
|
@ -83,7 +83,7 @@ class SFTP extends Common {
|
|||
}
|
||||
|
||||
$this->root
|
||||
= isset($params['root']) ? $this->cleanPath($params['root']) : '/';
|
||||
= isset($parameters['root']) ? $this->cleanPath($parameters['root']) : '/';
|
||||
|
||||
$this->root = '/' . ltrim($this->root, '/');
|
||||
$this->root = rtrim($this->root, '/') . '/';
|
||||
|
|
|
|||
|
|
@ -69,55 +69,55 @@ class SMB extends Common implements INotifyStorage {
|
|||
/** @var bool */
|
||||
protected $checkAcl;
|
||||
|
||||
public function __construct($params) {
|
||||
if (!isset($params['host'])) {
|
||||
public function __construct(array $parameters) {
|
||||
if (!isset($parameters['host'])) {
|
||||
throw new \Exception('Invalid configuration, no host provided');
|
||||
}
|
||||
|
||||
if (isset($params['auth'])) {
|
||||
$auth = $params['auth'];
|
||||
} elseif (isset($params['user']) && isset($params['password']) && isset($params['share'])) {
|
||||
[$workgroup, $user] = $this->splitUser($params['user']);
|
||||
$auth = new BasicAuth($user, $workgroup, $params['password']);
|
||||
if (isset($parameters['auth'])) {
|
||||
$auth = $parameters['auth'];
|
||||
} elseif (isset($parameters['user']) && isset($parameters['password']) && isset($parameters['share'])) {
|
||||
[$workgroup, $user] = $this->splitUser($parameters['user']);
|
||||
$auth = new BasicAuth($user, $workgroup, $parameters['password']);
|
||||
} else {
|
||||
throw new \Exception('Invalid configuration, no credentials provided');
|
||||
}
|
||||
|
||||
if (isset($params['logger'])) {
|
||||
if (!$params['logger'] instanceof LoggerInterface) {
|
||||
if (isset($parameters['logger'])) {
|
||||
if (!$parameters['logger'] instanceof LoggerInterface) {
|
||||
throw new \Exception(
|
||||
'Invalid logger. Got '
|
||||
. get_class($params['logger'])
|
||||
. get_class($parameters['logger'])
|
||||
. ' Expected ' . LoggerInterface::class
|
||||
);
|
||||
}
|
||||
$this->logger = $params['logger'];
|
||||
$this->logger = $parameters['logger'];
|
||||
} else {
|
||||
$this->logger = \OCP\Server::get(LoggerInterface::class);
|
||||
}
|
||||
|
||||
$options = new Options();
|
||||
if (isset($params['timeout'])) {
|
||||
$timeout = (int)$params['timeout'];
|
||||
if (isset($parameters['timeout'])) {
|
||||
$timeout = (int)$parameters['timeout'];
|
||||
if ($timeout > 0) {
|
||||
$options->setTimeout($timeout);
|
||||
}
|
||||
}
|
||||
$system = \OCP\Server::get(SystemBridge::class);
|
||||
$serverFactory = new ServerFactory($options, $system);
|
||||
$this->server = $serverFactory->createServer($params['host'], $auth);
|
||||
$this->share = $this->server->getShare(trim($params['share'], '/'));
|
||||
$this->server = $serverFactory->createServer($parameters['host'], $auth);
|
||||
$this->share = $this->server->getShare(trim($parameters['share'], '/'));
|
||||
|
||||
$this->root = $params['root'] ?? '/';
|
||||
$this->root = $parameters['root'] ?? '/';
|
||||
$this->root = '/' . ltrim($this->root, '/');
|
||||
$this->root = rtrim($this->root, '/') . '/';
|
||||
|
||||
$this->showHidden = isset($params['show_hidden']) && $params['show_hidden'];
|
||||
$this->caseSensitive = (bool)($params['case_sensitive'] ?? true);
|
||||
$this->checkAcl = isset($params['check_acl']) && $params['check_acl'];
|
||||
$this->showHidden = isset($parameters['show_hidden']) && $parameters['show_hidden'];
|
||||
$this->caseSensitive = (bool)($parameters['case_sensitive'] ?? true);
|
||||
$this->checkAcl = isset($parameters['check_acl']) && $parameters['check_acl'];
|
||||
|
||||
$this->statCache = new CappedMemoryCache();
|
||||
parent::__construct($params);
|
||||
parent::__construct($parameters);
|
||||
}
|
||||
|
||||
private function splitUser(string $user): array {
|
||||
|
|
|
|||
|
|
@ -122,44 +122,44 @@ class Swift extends Common {
|
|||
return $this->fetchObject($path) !== false;
|
||||
}
|
||||
|
||||
public function __construct($params) {
|
||||
if ((empty($params['key']) and empty($params['password']))
|
||||
or (empty($params['user']) && empty($params['userid'])) or empty($params['bucket'])
|
||||
or empty($params['region'])
|
||||
public function __construct(array $parameters) {
|
||||
if ((empty($parameters['key']) and empty($parameters['password']))
|
||||
or (empty($parameters['user']) && empty($parameters['userid'])) or empty($parameters['bucket'])
|
||||
or empty($parameters['region'])
|
||||
) {
|
||||
throw new StorageBadConfigException('API Key or password, Login, Bucket and Region have to be configured.');
|
||||
}
|
||||
|
||||
$user = $params['user'];
|
||||
$this->id = 'swift::' . $user . md5($params['bucket']);
|
||||
$user = $parameters['user'];
|
||||
$this->id = 'swift::' . $user . md5($parameters['bucket']);
|
||||
|
||||
$bucketUrl = new Uri($params['bucket']);
|
||||
$bucketUrl = new Uri($parameters['bucket']);
|
||||
if ($bucketUrl->getHost()) {
|
||||
$params['bucket'] = basename($bucketUrl->getPath());
|
||||
$params['endpoint_url'] = (string)$bucketUrl->withPath(dirname($bucketUrl->getPath()));
|
||||
$parameters['bucket'] = basename($bucketUrl->getPath());
|
||||
$parameters['endpoint_url'] = (string)$bucketUrl->withPath(dirname($bucketUrl->getPath()));
|
||||
}
|
||||
|
||||
if (empty($params['url'])) {
|
||||
$params['url'] = 'https://identity.api.rackspacecloud.com/v2.0/';
|
||||
if (empty($parameters['url'])) {
|
||||
$parameters['url'] = 'https://identity.api.rackspacecloud.com/v2.0/';
|
||||
}
|
||||
|
||||
if (empty($params['service_name'])) {
|
||||
$params['service_name'] = 'cloudFiles';
|
||||
if (empty($parameters['service_name'])) {
|
||||
$parameters['service_name'] = 'cloudFiles';
|
||||
}
|
||||
|
||||
$params['autocreate'] = true;
|
||||
$parameters['autocreate'] = true;
|
||||
|
||||
if (isset($params['domain'])) {
|
||||
$params['user'] = [
|
||||
'name' => $params['user'],
|
||||
'password' => $params['password'],
|
||||
if (isset($parameters['domain'])) {
|
||||
$parameters['user'] = [
|
||||
'name' => $parameters['user'],
|
||||
'password' => $parameters['password'],
|
||||
'domain' => [
|
||||
'name' => $params['domain'],
|
||||
'name' => $parameters['domain'],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
$this->params = $params;
|
||||
$this->params = $parameters;
|
||||
// FIXME: private class...
|
||||
$this->objectCache = new CappedMemoryCache();
|
||||
$this->connectionFactory = new SwiftFactory(
|
||||
|
|
@ -168,7 +168,7 @@ class Swift extends Common {
|
|||
\OC::$server->get(LoggerInterface::class)
|
||||
);
|
||||
$this->objectStore = new \OC\Files\ObjectStore\Swift($this->params, $this->connectionFactory);
|
||||
$this->bucket = $params['bucket'];
|
||||
$this->bucket = $parameters['bucket'];
|
||||
$this->mimeDetector = \OC::$server->get(IMimeTypeDetector::class);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,16 +89,16 @@ class SharedStorage extends Jail implements LegacyISharedStorage, ISharedStorage
|
|||
*/
|
||||
protected $storage;
|
||||
|
||||
public function __construct($arguments) {
|
||||
$this->ownerView = $arguments['ownerView'];
|
||||
public function __construct(array $parameters) {
|
||||
$this->ownerView = $parameters['ownerView'];
|
||||
$this->logger = \OC::$server->get(LoggerInterface::class);
|
||||
|
||||
$this->superShare = $arguments['superShare'];
|
||||
$this->groupedShares = $arguments['groupedShares'];
|
||||
$this->superShare = $parameters['superShare'];
|
||||
$this->groupedShares = $parameters['groupedShares'];
|
||||
|
||||
$this->user = $arguments['user'];
|
||||
if (isset($arguments['sharingDisabledForUser'])) {
|
||||
$this->sharingDisabledForUser = $arguments['sharingDisabledForUser'];
|
||||
$this->user = $parameters['user'];
|
||||
if (isset($parameters['sharingDisabledForUser'])) {
|
||||
$this->sharingDisabledForUser = $parameters['sharingDisabledForUser'];
|
||||
} else {
|
||||
$this->sharingDisabledForUser = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,15 @@ class AppdataPreviewObjectStoreStorage extends ObjectStoreStorage {
|
|||
private string $internalId;
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param array $parameters
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($params) {
|
||||
if (!isset($params['internal-id'])) {
|
||||
public function __construct(array $parameters) {
|
||||
if (!isset($parameters['internal-id'])) {
|
||||
throw new \Exception('missing id in parameters');
|
||||
}
|
||||
$this->internalId = (string)$params['internal-id'];
|
||||
parent::__construct($params);
|
||||
$this->internalId = (string)$parameters['internal-id'];
|
||||
parent::__construct($parameters);
|
||||
}
|
||||
|
||||
public function getId(): string {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class Azure implements IObjectStore {
|
|||
/**
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct($parameters) {
|
||||
public function __construct(array $parameters) {
|
||||
$this->containerName = $parameters['container'];
|
||||
$this->accountName = $parameters['account_name'];
|
||||
$this->accountKey = $parameters['account_key'];
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage
|
|||
/**
|
||||
* The home user storage requires a user object to create a unique storage id
|
||||
*
|
||||
* @param array $params
|
||||
* @param array $parameters
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($params) {
|
||||
if (! isset($params['user']) || ! $params['user'] instanceof IUser) {
|
||||
public function __construct(array $parameters) {
|
||||
if (! isset($parameters['user']) || ! $parameters['user'] instanceof IUser) {
|
||||
throw new Exception('missing user object in parameters');
|
||||
}
|
||||
$this->user = $params['user'];
|
||||
parent::__construct($params);
|
||||
$this->user = $parameters['user'];
|
||||
parent::__construct($parameters);
|
||||
}
|
||||
|
||||
public function getId(): string {
|
||||
|
|
|
|||
|
|
@ -41,27 +41,27 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
|
|||
private bool $preserveCacheItemsOnDelete = false;
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param array $parameters
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($params) {
|
||||
if (isset($params['objectstore']) && $params['objectstore'] instanceof IObjectStore) {
|
||||
$this->objectStore = $params['objectstore'];
|
||||
public function __construct(array $parameters) {
|
||||
if (isset($parameters['objectstore']) && $parameters['objectstore'] instanceof IObjectStore) {
|
||||
$this->objectStore = $parameters['objectstore'];
|
||||
} else {
|
||||
throw new \Exception('missing IObjectStore instance');
|
||||
}
|
||||
if (isset($params['storageid'])) {
|
||||
$this->id = 'object::store:' . $params['storageid'];
|
||||
if (isset($parameters['storageid'])) {
|
||||
$this->id = 'object::store:' . $parameters['storageid'];
|
||||
} else {
|
||||
$this->id = 'object::store:' . $this->objectStore->getStorageId();
|
||||
}
|
||||
if (isset($params['objectPrefix'])) {
|
||||
$this->objectPrefix = $params['objectPrefix'];
|
||||
if (isset($parameters['objectPrefix'])) {
|
||||
$this->objectPrefix = $parameters['objectPrefix'];
|
||||
}
|
||||
if (isset($params['validateWrites'])) {
|
||||
$this->validateWrites = (bool)$params['validateWrites'];
|
||||
if (isset($parameters['validateWrites'])) {
|
||||
$this->validateWrites = (bool)$parameters['validateWrites'];
|
||||
}
|
||||
$this->handleCopiesAsOwned = (bool)($params['handleCopiesAsOwned'] ?? false);
|
||||
$this->handleCopiesAsOwned = (bool)($parameters['handleCopiesAsOwned'] ?? false);
|
||||
|
||||
$this->logger = \OCP\Server::get(LoggerInterface::class);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class S3 implements IObjectStore, IObjectStoreMultiPartUpload {
|
|||
use S3ConnectionTrait;
|
||||
use S3ObjectTrait;
|
||||
|
||||
public function __construct($parameters) {
|
||||
public function __construct(array $parameters) {
|
||||
$parameters['primary_storage'] = true;
|
||||
$this->parseParams($parameters);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage,
|
|||
private ?LoggerInterface $logger = null;
|
||||
private ?IFilenameValidator $filenameValidator = null;
|
||||
|
||||
public function __construct($parameters) {
|
||||
public function __construct(array $parameters) {
|
||||
}
|
||||
|
||||
protected function remove(string $path): bool {
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ class CommonTest extends \OC\Files\Storage\Common {
|
|||
*/
|
||||
private $storage;
|
||||
|
||||
public function __construct($params) {
|
||||
$this->storage = new \OC\Files\Storage\Local($params);
|
||||
public function __construct(array $parameters) {
|
||||
$this->storage = new \OC\Files\Storage\Local($parameters);
|
||||
}
|
||||
|
||||
public function getId(): string {
|
||||
|
|
|
|||
|
|
@ -83,14 +83,14 @@ class DAV extends Common {
|
|||
];
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param array $parameters
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function __construct($params) {
|
||||
public function __construct(array $parameters) {
|
||||
$this->statCache = new ArrayCache();
|
||||
$this->httpClientService = Server::get(IClientService::class);
|
||||
if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
|
||||
$host = $params['host'];
|
||||
if (isset($parameters['host']) && isset($parameters['user']) && isset($parameters['password'])) {
|
||||
$host = $parameters['host'];
|
||||
//remove leading http[s], will be generated in createBaseUri()
|
||||
if (str_starts_with($host, 'https://')) {
|
||||
$host = substr($host, 8);
|
||||
|
|
@ -98,16 +98,16 @@ class DAV extends Common {
|
|||
$host = substr($host, 7);
|
||||
}
|
||||
$this->host = $host;
|
||||
$this->user = $params['user'];
|
||||
$this->password = $params['password'];
|
||||
if (isset($params['authType'])) {
|
||||
$this->authType = $params['authType'];
|
||||
$this->user = $parameters['user'];
|
||||
$this->password = $parameters['password'];
|
||||
if (isset($parameters['authType'])) {
|
||||
$this->authType = $parameters['authType'];
|
||||
}
|
||||
if (isset($params['secure'])) {
|
||||
if (is_string($params['secure'])) {
|
||||
$this->secure = ($params['secure'] === 'true');
|
||||
if (isset($parameters['secure'])) {
|
||||
if (is_string($parameters['secure'])) {
|
||||
$this->secure = ($parameters['secure'] === 'true');
|
||||
} else {
|
||||
$this->secure = (bool)$params['secure'];
|
||||
$this->secure = (bool)$parameters['secure'];
|
||||
}
|
||||
} else {
|
||||
$this->secure = false;
|
||||
|
|
@ -116,7 +116,7 @@ class DAV extends Common {
|
|||
// inject mock for testing
|
||||
$this->certManager = \OC::$server->getCertificateManager();
|
||||
}
|
||||
$this->root = $params['root'] ?? '/';
|
||||
$this->root = $parameters['root'] ?? '/';
|
||||
$this->root = '/' . ltrim($this->root, '/');
|
||||
$this->root = rtrim($this->root, '/') . '/';
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ class FailedStorage extends Common {
|
|||
protected $e;
|
||||
|
||||
/**
|
||||
* @param array $params ['exception' => \Exception]
|
||||
* @param array $parameters ['exception' => \Exception]
|
||||
*/
|
||||
public function __construct($params) {
|
||||
$this->e = $params['exception'];
|
||||
public function __construct(array $parameters) {
|
||||
$this->e = $parameters['exception'];
|
||||
if (!$this->e) {
|
||||
throw new \InvalidArgumentException('Missing "exception" argument in FailedStorage constructor');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ class Home extends Local implements \OCP\Files\IHomeStorage {
|
|||
/**
|
||||
* Construct a Home storage instance
|
||||
*
|
||||
* @param array $arguments array with "user" containing the
|
||||
* storage owner
|
||||
* @param array $parameters array with "user" containing the
|
||||
* storage owner
|
||||
*/
|
||||
public function __construct($arguments) {
|
||||
$this->user = $arguments['user'];
|
||||
public function __construct(array $parameters) {
|
||||
$this->user = $parameters['user'];
|
||||
$datadir = $this->user->getHome();
|
||||
$this->id = 'home::' . $this->user->getUID();
|
||||
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ class Local extends \OC\Files\Storage\Common {
|
|||
|
||||
protected bool $caseInsensitive = false;
|
||||
|
||||
public function __construct($arguments) {
|
||||
if (!isset($arguments['datadir']) || !is_string($arguments['datadir'])) {
|
||||
public function __construct(array $parameters) {
|
||||
if (!isset($parameters['datadir']) || !is_string($parameters['datadir'])) {
|
||||
throw new \InvalidArgumentException('No data directory set for local storage');
|
||||
}
|
||||
$this->datadir = str_replace('//', '/', $arguments['datadir']);
|
||||
$this->datadir = str_replace('//', '/', $parameters['datadir']);
|
||||
// some crazy code uses a local storage on root...
|
||||
if ($this->datadir === '/') {
|
||||
$this->realDataDir = $this->datadir;
|
||||
|
|
@ -64,7 +64,7 @@ class Local extends \OC\Files\Storage\Common {
|
|||
// support Write-Once-Read-Many file systems
|
||||
$this->unlinkOnTruncate = $this->config->getSystemValueBool('localstorage.unlink_on_truncate', false);
|
||||
|
||||
if (isset($arguments['isExternal']) && $arguments['isExternal'] && !$this->stat('')) {
|
||||
if (isset($parameters['isExternal']) && $parameters['isExternal'] && !$this->stat('')) {
|
||||
// data dir not accessible or available, can happen when using an external storage of type Local
|
||||
// on an unmounted system mount point
|
||||
throw new StorageNotAvailableException('Local storage path does not exist "' . $this->getSourcePath('') . '"');
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace OC\Files\Storage;
|
|||
* local storage backend in temporary folder for testing purpose
|
||||
*/
|
||||
class Temporary extends Local {
|
||||
public function __construct($arguments = []) {
|
||||
public function __construct(array $parameters = []) {
|
||||
parent::__construct(['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class Availability extends Wrapper {
|
|||
/** @var IConfig */
|
||||
protected $config;
|
||||
|
||||
public function __construct($parameters) {
|
||||
public function __construct(array $parameters) {
|
||||
$this->config = $parameters['config'] ?? \OC::$server->getConfig();
|
||||
parent::__construct($parameters);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class Encoding extends Wrapper {
|
|||
/**
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct($parameters) {
|
||||
public function __construct(array $parameters) {
|
||||
$this->storage = $parameters['storage'];
|
||||
$this->namesCache = new CappedMemoryCache();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class Encryption extends Wrapper {
|
|||
* @param array $parameters
|
||||
*/
|
||||
public function __construct(
|
||||
$parameters,
|
||||
array $parameters,
|
||||
private IManager $encryptionManager,
|
||||
private Util $util,
|
||||
private LoggerInterface $logger,
|
||||
|
|
|
|||
|
|
@ -30,14 +30,14 @@ class Jail extends Wrapper {
|
|||
protected $rootPath;
|
||||
|
||||
/**
|
||||
* @param array $arguments ['storage' => $storage, 'root' => $root]
|
||||
* @param array $parameters ['storage' => $storage, 'root' => $root]
|
||||
*
|
||||
* $storage: The storage that will be wrapper
|
||||
* $root: The folder in the wrapped storage that will become the root folder of the wrapped storage
|
||||
*/
|
||||
public function __construct($arguments) {
|
||||
parent::__construct($arguments);
|
||||
$this->rootPath = $arguments['root'];
|
||||
public function __construct(array $parameters) {
|
||||
parent::__construct($parameters);
|
||||
$this->rootPath = $parameters['root'];
|
||||
}
|
||||
|
||||
public function getUnjailedPath(string $path): string {
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ class KnownMtime extends Wrapper {
|
|||
private CappedMemoryCache $knowMtimes;
|
||||
private ClockInterface $clock;
|
||||
|
||||
public function __construct($arguments) {
|
||||
parent::__construct($arguments);
|
||||
public function __construct(array $parameters) {
|
||||
parent::__construct($parameters);
|
||||
$this->knowMtimes = new CappedMemoryCache();
|
||||
$this->clock = $arguments['clock'];
|
||||
$this->clock = $parameters['clock'];
|
||||
}
|
||||
|
||||
public function file_put_contents(string $path, mixed $data): int|float|false {
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@ class PermissionsMask extends Wrapper {
|
|||
private $mask;
|
||||
|
||||
/**
|
||||
* @param array $arguments ['storage' => $storage, 'mask' => $mask]
|
||||
* @param array $parameters ['storage' => $storage, 'mask' => $mask]
|
||||
*
|
||||
* $storage: The storage the permissions mask should be applied on
|
||||
* $mask: The permission bits that should be kept, a combination of the \OCP\Constant::PERMISSION_ constants
|
||||
*/
|
||||
public function __construct($arguments) {
|
||||
parent::__construct($arguments);
|
||||
$this->mask = $arguments['mask'];
|
||||
public function __construct(array $parameters) {
|
||||
parent::__construct($parameters);
|
||||
$this->mask = $parameters['mask'];
|
||||
}
|
||||
|
||||
private function checkMask(int $permissions): bool {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Quota extends Wrapper {
|
|||
/**
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct($parameters) {
|
||||
public function __construct(array $parameters) {
|
||||
parent::__construct($parameters);
|
||||
$this->quota = $parameters['quota'] ?? null;
|
||||
$this->quotaCallback = $parameters['quotaCallback'] ?? null;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea
|
|||
/**
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function __construct($parameters) {
|
||||
public function __construct(array $parameters) {
|
||||
$this->storage = $parameters['storage'];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use OCP\Files\Cache\ICache;
|
|||
use OCP\Files\Storage\IStorage;
|
||||
|
||||
class NullStorage extends Common {
|
||||
public function __construct($parameters) {
|
||||
public function __construct(array $parameters) {
|
||||
parent::__construct($parameters);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class LocalTest extends Storage {
|
|||
public function testInvalidArgumentsNoArray(): void {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
new \OC\Files\Storage\Local(null);
|
||||
new \OC\Files\Storage\Local([]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ use Test\TestCase;
|
|||
class DummyWrapper extends Wrapper {
|
||||
public $data;
|
||||
|
||||
public function __construct($arguments) {
|
||||
parent::__construct($arguments);
|
||||
if (isset($arguments['data'])) {
|
||||
$this->data = $arguments['data'];
|
||||
public function __construct(array $parameters) {
|
||||
parent::__construct($parameters);
|
||||
if (isset($parameters['data'])) {
|
||||
$this->data = $parameters['data'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class HelperStorageTest extends \Test\TestCase {
|
|||
private function getStorageMock($freeSpace = 12) {
|
||||
$this->storageMock = $this->getMockBuilder(Temporary::class)
|
||||
->setMethods(['free_space'])
|
||||
->setConstructorArgs([''])
|
||||
->setConstructorArgs([[]])
|
||||
->getMock();
|
||||
|
||||
$this->storageMock->expects($this->once())
|
||||
|
|
|
|||
Loading…
Reference in a new issue