aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib/Lib')
-rw-r--r--apps/files_external/lib/Lib/Backend/SMB.php23
-rw-r--r--apps/files_external/lib/Lib/MissingDependency.php13
-rw-r--r--apps/files_external/lib/Lib/Storage/Swift.php26
3 files changed, 44 insertions, 18 deletions
diff --git a/apps/files_external/lib/Lib/Backend/SMB.php b/apps/files_external/lib/Lib/Backend/SMB.php
index b246b0638f0..3549f69cbe3 100644
--- a/apps/files_external/lib/Lib/Backend/SMB.php
+++ b/apps/files_external/lib/Lib/Backend/SMB.php
@@ -10,19 +10,20 @@ namespace OCA\Files_External\Lib\Backend;
use Icewind\SMB\BasicAuth;
use Icewind\SMB\KerberosApacheAuth;
use Icewind\SMB\KerberosAuth;
+use Icewind\SMB\Native\NativeServer;
+use Icewind\SMB\Wrapped\Server;
use OCA\Files_External\Lib\Auth\AuthMechanism;
use OCA\Files_External\Lib\Auth\Password\Password;
use OCA\Files_External\Lib\Auth\SMB\KerberosApacheAuth as KerberosApacheAuthMechanism;
use OCA\Files_External\Lib\DefinitionParameter;
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
-use OCA\Files_External\Lib\LegacyDependencyCheckPolyfill;
+use OCA\Files_External\Lib\MissingDependency;
+use OCA\Files_External\Lib\Storage\SystemBridge;
use OCA\Files_External\Lib\StorageConfig;
use OCP\IL10N;
use OCP\IUser;
class SMB extends Backend {
- use LegacyDependencyCheckPolyfill;
-
public function __construct(IL10N $l, Password $legacyAuth) {
$this
->setIdentifier('smb')
@@ -122,4 +123,20 @@ class SMB extends Backend {
$storage->setBackendOption('auth', $smbAuth);
}
+
+ public function checkDependencies() {
+ $system = \OCP\Server::get(SystemBridge::class);
+ if (NativeServer::available($system)) {
+ return [];
+ } elseif (Server::available($system)) {
+ $missing = new MissingDependency('php-smbclient');
+ $missing->setOptional(true);
+ $missing->setMessage('The php-smbclient library provides improved compatibility and performance for SMB storages.');
+ return [$missing];
+ } else {
+ $missing = new MissingDependency('php-smbclient');
+ $missing->setMessage('Either the php-smbclient library (preferred) or the smbclient binary is required for SMB storages.');
+ return [$missing, new MissingDependency('smbclient')];
+ }
+ }
}
diff --git a/apps/files_external/lib/Lib/MissingDependency.php b/apps/files_external/lib/Lib/MissingDependency.php
index 5c2c6880f23..da4cbb1de46 100644
--- a/apps/files_external/lib/Lib/MissingDependency.php
+++ b/apps/files_external/lib/Lib/MissingDependency.php
@@ -12,13 +12,14 @@ namespace OCA\Files_External\Lib;
class MissingDependency {
/** @var string|null Custom message */
- private $message = null;
+ private ?string $message = null;
+ private bool $optional = false;
/**
* @param string $dependency
*/
public function __construct(
- private $dependency,
+ private readonly string $dependency,
) {
}
@@ -38,4 +39,12 @@ class MissingDependency {
$this->message = $message;
return $this;
}
+
+ public function isOptional(): bool {
+ return $this->optional;
+ }
+
+ public function setOptional(bool $optional): void {
+ $this->optional = $optional;
+ }
}
diff --git a/apps/files_external/lib/Lib/Storage/Swift.php b/apps/files_external/lib/Lib/Storage/Swift.php
index a71331766d4..e80570f14ba 100644
--- a/apps/files_external/lib/Lib/Storage/Swift.php
+++ b/apps/files_external/lib/Lib/Storage/Swift.php
@@ -288,7 +288,6 @@ class Swift extends Common {
public function stat(string $path): array|false {
$path = $this->normalizePath($path);
-
if ($path === '.') {
$path = '';
} elseif ($this->is_dir($path)) {
@@ -308,22 +307,23 @@ class Swift extends Common {
return false;
}
- $dateTime = $object->lastModified ? \DateTime::createFromFormat(\DateTime::RFC1123, $object->lastModified) : false;
- $mtime = $dateTime ? $dateTime->getTimestamp() : null;
- $objectMetadata = $object->getMetadata();
- if (isset($objectMetadata['timestamp'])) {
- $mtime = $objectMetadata['timestamp'];
+ $mtime = null;
+ if (!empty($object->lastModified)) {
+ $dateTime = \DateTime::createFromFormat(\DateTime::RFC1123, $object->lastModified);
+ if ($dateTime !== false) {
+ $mtime = $dateTime->getTimestamp();
+ }
}
- if (!empty($mtime)) {
- $mtime = floor($mtime);
+ if (is_numeric($object->getMetadata()['timestamp'] ?? null)) {
+ $mtime = (float)$object->getMetadata()['timestamp'];
}
- $stat = [];
- $stat['size'] = (int)$object->contentLength;
- $stat['mtime'] = $mtime;
- $stat['atime'] = time();
- return $stat;
+ return [
+ 'size' => (int)$object->contentLength,
+ 'mtime' => isset($mtime) ? (int)floor($mtime) : null,
+ 'atime' => time(),
+ ];
}
public function filetype(string $path) {