diff options
author | Daniel <mail@danielkesselberg.de> | 2024-11-28 10:40:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-28 10:40:20 +0100 |
commit | b1ffafc1dd14d264e5ec81d5500575ab6935ad01 (patch) | |
tree | aade2898a62f1521d34150be59a3d55ba316f238 | |
parent | a0ae6404cbd64b6ee1a22db31a1d53a500b42973 (diff) | |
parent | e71880d63d7e90321770afd155d936e08919d251 (diff) | |
download | nextcloud-server-b1ffafc1dd14d264e5ec81d5500575ab6935ad01.tar.gz nextcloud-server-b1ffafc1dd14d264e5ec81d5500575ab6935ad01.zip |
Merge pull request #49496 from nextcloud/backport/49494/stable29
[stable29] fix: throw correct exception type when we can't verify if an s3 bucket exists
-rw-r--r-- | .github/workflows/files-external-smb-kerberos.yml | 6 | ||||
-rw-r--r-- | lib/private/Files/ObjectStore/S3ConnectionTrait.php | 11 | ||||
-rw-r--r-- | lib/private/Files/SetupManager.php | 4 |
3 files changed, 14 insertions, 7 deletions
diff --git a/.github/workflows/files-external-smb-kerberos.yml b/.github/workflows/files-external-smb-kerberos.yml index 61b4b482513..53f40844409 100644 --- a/.github/workflows/files-external-smb-kerberos.yml +++ b/.github/workflows/files-external-smb-kerberos.yml @@ -51,6 +51,12 @@ jobs: repository: nextcloud/user_saml path: apps/user_saml + - name: Install user_saml + run: | + cd apps/user_saml + composer i + cd ../.. + - name: Pull images run: | docker pull ghcr.io/icewind1991/samba-krb-test-dc diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php index 86c665aa5f6..c7191ba2858 100644 --- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php +++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php @@ -40,6 +40,7 @@ use Aws\S3\Exception\S3Exception; use Aws\S3\S3Client; use GuzzleHttp\Promise; use GuzzleHttp\Promise\RejectedPromise; +use OCP\Files\StorageNotAvailableException; use OCP\ICertificateManager; use OCP\Server; use Psr\Log\LoggerInterface; @@ -155,12 +156,12 @@ trait S3ConnectionTrait { $logger->debug('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.', ['app' => 'objectstore']); } - + if ($this->params['verify_bucket_exists'] && !$this->connection->doesBucketExist($this->bucket)) { try { $logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']); if (!$this->connection::isBucketDnsCompatible($this->bucket)) { - throw new \Exception("The bucket will not be created because the name is not dns compatible, please correct it: " . $this->bucket); + throw new StorageNotAvailableException("The bucket will not be created because the name is not dns compatible, please correct it: " . $this->bucket); } $this->connection->createBucket(['Bucket' => $this->bucket]); $this->testTimeout(); @@ -170,17 +171,17 @@ trait S3ConnectionTrait { 'app' => 'objectstore', ]); if ($e->getAwsErrorCode() !== 'BucketAlreadyOwnedByYou') { - throw new \Exception('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage()); + throw new StorageNotAvailableException('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage()); } } } - + // google cloud's s3 compatibility doesn't like the EncodingType parameter if (strpos($base_url, 'storage.googleapis.com')) { $this->connection->getHandlerList()->remove('s3.auto_encode'); } } catch (S3Exception $e) { - throw new \Exception('S3 service is unable to handle request: ' . $e->getMessage()); + throw new StorageNotAvailableException('S3 service is unable to handle request: ' . $e->getMessage()); } return $this->connection; diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php index d559f88c2f9..436ea4eb225 100644 --- a/lib/private/Files/SetupManager.php +++ b/lib/private/Files/SetupManager.php @@ -39,7 +39,7 @@ use OC\Share20\ShareDisableChecker; use OC_App; use OC_Hook; use OC_Util; -use OCA\Files_External\Config\ConfigAdapter; +use OCA\Files_External\Config\ExternalMountPoint; use OCA\Files_Sharing\External\Mount; use OCA\Files_Sharing\ISharedMountPoint; use OCA\Files_Sharing\SharedMount; @@ -149,7 +149,7 @@ class SetupManager { // install storage availability wrapper, before most other wrappers Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, IStorage $storage, IMountPoint $mount) { - $externalMount = $mount instanceof ConfigAdapter || $mount instanceof Mount; + $externalMount = $mount instanceof ExternalMountPoint || $mount instanceof Mount; if ($externalMount && !$storage->isLocal()) { return new Availability(['storage' => $storage]); } |