summaryrefslogtreecommitdiffstats
path: root/apps/files_external/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r--apps/files_external/lib/Config/ExternalMountPoint.php2
-rw-r--r--apps/files_external/lib/Lib/Storage/AmazonS3.php16
-rw-r--r--apps/files_external/lib/Lib/Storage/SFTP.php3
-rw-r--r--apps/files_external/lib/Lib/Storage/SMB.php26
4 files changed, 35 insertions, 12 deletions
diff --git a/apps/files_external/lib/Config/ExternalMountPoint.php b/apps/files_external/lib/Config/ExternalMountPoint.php
index 985e70bee03..090e1c77cdf 100644
--- a/apps/files_external/lib/Config/ExternalMountPoint.php
+++ b/apps/files_external/lib/Config/ExternalMountPoint.php
@@ -34,7 +34,7 @@ class ExternalMountPoint extends MountPoint {
public function __construct(StorageConfig $storageConfig, $storage, $mountpoint, $arguments = null, $loader = null, $mountOptions = null, $mountId = null) {
$this->storageConfig = $storageConfig;
- parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId);
+ parent::__construct($storage, $mountpoint, $arguments, $loader, $mountOptions, $mountId, ConfigAdapter::class);
}
public function getMountType() {
diff --git a/apps/files_external/lib/Lib/Storage/AmazonS3.php b/apps/files_external/lib/Lib/Storage/AmazonS3.php
index 2c01a803840..cfd78689fa4 100644
--- a/apps/files_external/lib/Lib/Storage/AmazonS3.php
+++ b/apps/files_external/lib/Lib/Storage/AmazonS3.php
@@ -732,8 +732,7 @@ class AmazonS3 extends \OC\Files\Storage\Common {
if ($this->versioningEnabled === null) {
$cached = $this->memCache->get('versioning-enabled::' . $this->getBucket());
if ($cached === null) {
- $result = $this->getConnection()->getBucketVersioning(['Bucket' => $this->getBucket()]);
- $this->versioningEnabled = $result->get('Status') === 'Enabled';
+ $this->versioningEnabled = $this->getVersioningStatusFromBucket();
$this->memCache->set('versioning-enabled::' . $this->getBucket(), $this->versioningEnabled, 60);
} else {
$this->versioningEnabled = $cached;
@@ -742,6 +741,19 @@ class AmazonS3 extends \OC\Files\Storage\Common {
return $this->versioningEnabled;
}
+ protected function getVersioningStatusFromBucket(): bool {
+ try {
+ $result = $this->getConnection()->getBucketVersioning(['Bucket' => $this->getBucket()]);
+ return $result->get('Status') === 'Enabled';
+ } catch (S3Exception $s3Exception) {
+ // This is needed for compatibility with Storj gateway which does not support versioning yet
+ if ($s3Exception->getAwsErrorCode() === 'NotImplemented') {
+ return false;
+ }
+ throw $s3Exception;
+ }
+ }
+
public function hasUpdated($path, $time) {
// for files we can get the proper mtime
if ($path !== '' && $object = $this->headObject($path)) {
diff --git a/apps/files_external/lib/Lib/Storage/SFTP.php b/apps/files_external/lib/Lib/Storage/SFTP.php
index ae049007cdc..e46f60d0be4 100644
--- a/apps/files_external/lib/Lib/Storage/SFTP.php
+++ b/apps/files_external/lib/Lib/Storage/SFTP.php
@@ -327,6 +327,9 @@ class SFTP extends \OC\Files\Storage\Common {
public function filetype($path) {
try {
$stat = $this->getConnection()->stat($this->absPath($path));
+ if (!is_array($stat) || !array_key_exists('type', $stat)) {
+ return false;
+ }
if ((int) $stat['type'] === NET_SFTP_TYPE_REGULAR) {
return 'file';
}
diff --git a/apps/files_external/lib/Lib/Storage/SMB.php b/apps/files_external/lib/Lib/Storage/SMB.php
index 28a2d6de7cc..6464264f3a4 100644
--- a/apps/files_external/lib/Lib/Storage/SMB.php
+++ b/apps/files_external/lib/Lib/Storage/SMB.php
@@ -43,6 +43,7 @@ use Icewind\SMB\Exception\ConnectException;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\ForbiddenException;
use Icewind\SMB\Exception\InvalidArgumentException;
+use Icewind\SMB\Exception\InvalidTypeException;
use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\Exception\OutOfSpaceException;
use Icewind\SMB\Exception\TimedOutException;
@@ -84,7 +85,7 @@ class SMB extends Common implements INotifyStorage {
protected $root;
/**
- * @var \Icewind\SMB\IFileInfo[]
+ * @var IFileInfo[]
*/
protected $statCache;
@@ -179,20 +180,24 @@ class SMB extends Common implements INotifyStorage {
/**
* @param string $path
- * @return \Icewind\SMB\IFileInfo
+ * @return IFileInfo
* @throws StorageAuthException
*/
protected function getFileInfo($path) {
try {
$path = $this->buildPath($path);
- if (!isset($this->statCache[$path])) {
- $this->statCache[$path] = $this->share->stat($path);
+ $cached = $this->statCache[$path] ?? null;
+ if ($cached instanceof IFileInfo) {
+ return $cached;
+ } else {
+ $stat = $this->share->stat($path);
+ $this->statCache[$path] = $stat;
+ return $stat;
}
- return $this->statCache[$path];
} catch (ConnectException $e) {
$this->throwUnavailable($e);
} catch (ForbiddenException $e) {
- // with php-smbclient, this exceptions is thrown when the provided password is invalid.
+ // with php-smbclient, this exception is thrown when the provided password is invalid.
// Possible is also ForbiddenException with a different error code, so we check it.
if ($e->getCode() === 1) {
$this->throwUnavailable($e);
@@ -203,6 +208,7 @@ class SMB extends Common implements INotifyStorage {
/**
* @param \Exception $e
+ * @return never
* @throws StorageAuthException
*/
protected function throwUnavailable(\Exception $e) {
@@ -230,7 +236,7 @@ class SMB extends Common implements INotifyStorage {
/**
* @param string $path
- * @return \Icewind\SMB\IFileInfo[]
+ * @return \Generator<IFileInfo>
* @throws StorageNotAvailableException
*/
protected function getFolderContents($path): iterable {
@@ -241,6 +247,8 @@ class SMB extends Common implements INotifyStorage {
} catch (ForbiddenException $e) {
$this->logger->critical($e->getMessage(), ['exception' => $e]);
throw new NotPermittedException();
+ } catch (InvalidTypeException $e) {
+ return;
}
foreach ($files as $file) {
$this->statCache[$path . '/' . $file->getName()] = $file;
@@ -281,7 +289,7 @@ class SMB extends Common implements INotifyStorage {
}
/**
- * @param \Icewind\SMB\IFileInfo $info
+ * @param IFileInfo $info
* @return array
*/
protected function formatInfo($info) {
@@ -613,7 +621,7 @@ class SMB extends Common implements INotifyStorage {
return false;
}
$names = array_map(function ($info) {
- /** @var \Icewind\SMB\IFileInfo $info */
+ /** @var IFileInfo $info */
return $info->getName();
}, iterator_to_array($files));
return IteratorDirectory::wrap($names);