aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGit'Fellow <12234510+solracsf@users.noreply.github.com>2024-09-04 11:17:55 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-09-06 12:44:48 +0200
commita36738dbfc12c98560662c939f1415c83cf630c8 (patch)
tree35ada1fa7a40ac504a19991a2cfbace93d20a5d7 /lib
parentba73beaac12714869f4f4c7808e9b610c10ea0f0 (diff)
downloadnextcloud-server-a36738dbfc12c98560662c939f1415c83cf630c8.tar.gz
nextcloud-server-a36738dbfc12c98560662c939f1415c83cf630c8.zip
chore(storage): refactor some code portions
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com> chore: revert portion Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/Storage/DAV.php46
1 files changed, 16 insertions, 30 deletions
diff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index 7abc0ccc182..ac9b7a72855 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -23,6 +23,7 @@ use OCP\Files\StorageNotAvailableException;
use OCP\Http\Client\IClientService;
use OCP\ICertificateManager;
use OCP\IConfig;
+use OCP\Server;
use OCP\Util;
use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerInterface;
@@ -86,7 +87,7 @@ class DAV extends Common {
*/
public function __construct($params) {
$this->statCache = new ArrayCache();
- $this->httpClientService = \OC::$server->get(IClientService::class);
+ $this->httpClientService = Server::get(IClientService::class);
if (isset($params['host']) && isset($params['user']) && isset($params['password'])) {
$host = $params['host'];
//remove leading http[s], will be generated in createBaseUri()
@@ -120,10 +121,10 @@ class DAV extends Common {
} else {
throw new \Exception('Invalid webdav storage configuration');
}
- $this->logger = \OC::$server->get(LoggerInterface::class);
- $this->eventLogger = \OC::$server->get(IEventLogger::class);
+ $this->logger = Server::get(LoggerInterface::class);
+ $this->eventLogger = Server::get(IEventLogger::class);
// This timeout value will be used for the download and upload of files
- $this->timeout = \OC::$server->get(IConfig::class)->getSystemValueInt('davstorage.request_timeout', 30);
+ $this->timeout = Server::get(IConfig::class)->getSystemValueInt('davstorage.request_timeout', 30);
$this->mimeTypeDetector = \OC::$server->getMimeTypeDetector();
}
@@ -142,7 +143,7 @@ class DAV extends Common {
$settings['authType'] = $this->authType;
}
- $proxy = \OC::$server->getConfig()->getSystemValueString('proxy', '');
+ $proxy = Server::get(IConfig::class)->getSystemValueString('proxy', '');
if ($proxy !== '') {
$settings['proxy'] = $proxy;
}
@@ -287,7 +288,7 @@ class DAV extends Common {
/** @var ResourceType[] $response */
$responseType = $response['{DAV:}resourcetype']->getValue();
}
- return (count($responseType) > 0 and $responseType[0] == '{DAV:}collection') ? 'dir' : 'file';
+ return (count($responseType) > 0 && $responseType[0] == '{DAV:}collection') ? 'dir' : 'file';
} catch (\Exception $e) {
$this->convertException($e, $path);
}
@@ -352,7 +353,7 @@ class DAV extends Common {
if ($response->getStatusCode() === Http::STATUS_LOCKED) {
throw new \OCP\Lock\LockedException($path);
} else {
- \OC::$server->get(LoggerInterface::class)->error('Guzzle get returned status code ' . $response->getStatusCode(), ['app' => 'webdav client']);
+ Server::get(LoggerInterface::class)->error('Guzzle get returned status code ' . $response->getStatusCode(), ['app' => 'webdav client']);
}
}
@@ -380,7 +381,7 @@ class DAV extends Common {
if (!$this->isUpdatable($path)) {
return false;
}
- if ($mode === 'w' or $mode === 'w+') {
+ if ($mode === 'w' || $mode === 'w+') {
$tmpFile = $tempManager->getTemporaryFile($ext);
} else {
$tmpFile = $this->getCachedFile($path);
@@ -586,7 +587,7 @@ class DAV extends Common {
/** @var ResourceType[] $response */
$responseType = $response['{DAV:}resourcetype']->getValue();
}
- $type = (count($responseType) > 0 and $responseType[0] == '{DAV:}collection') ? 'dir' : 'file';
+ $type = (count($responseType) > 0 && $responseType[0] == '{DAV:}collection') ? 'dir' : 'file';
if ($type === 'dir') {
$mimeType = 'httpd/unix-directory';
} elseif (isset($response['{DAV:}getcontenttype'])) {
@@ -625,21 +626,14 @@ class DAV extends Common {
/** {@inheritdoc} */
public function stat($path) {
$meta = $this->getMetaData($path);
- if (!$meta) {
- return false;
- } else {
- return $meta;
- }
+ return $meta ?: false;
+
}
/** {@inheritdoc} */
public function getMimeType($path) {
$meta = $this->getMetaData($path);
- if ($meta) {
- return $meta['mimetype'];
- } else {
- return false;
- }
+ return $meta ? $meta['mimetype'] : false;
}
/**
@@ -724,21 +718,13 @@ class DAV extends Common {
/** {@inheritdoc} */
public function getPermissions($path) {
$stat = $this->getMetaData($path);
- if ($stat) {
- return $stat['permissions'];
- } else {
- return 0;
- }
+ return $stat ? $stat['permissions'] : 0;
}
/** {@inheritdoc} */
public function getETag($path) {
$meta = $this->getMetaData($path);
- if ($meta) {
- return $meta['etag'];
- } else {
- return null;
- }
+ return $meta ? $meta['etag'] : null;
}
/**
@@ -838,7 +824,7 @@ class DAV extends Common {
* @throws ForbiddenException if the action is not allowed
*/
protected function convertException(Exception $e, $path = '') {
- \OC::$server->get(LoggerInterface::class)->debug($e->getMessage(), ['app' => 'files_external', 'exception' => $e]);
+ Server::get(LoggerInterface::class)->debug($e->getMessage(), ['app' => 'files_external', 'exception' => $e]);
if ($e instanceof ClientHttpException) {
if ($e->getHttpStatus() === Http::STATUS_LOCKED) {
throw new \OCP\Lock\LockedException($path);