From de84623f2fc98c1e304b42cc744afa12fc5cf60c Mon Sep 17 00:00:00 2001 From: philenius <philenius@users.noreply.github.com> Date: Wed, 25 Nov 2020 19:13:19 +0100 Subject: [PATCH] change return value of bucketExists() Set the return value of the function bucketExists() to 'true' only if the buckets exists AND the user has permission to access it. --- lib/src/minio.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/minio.dart b/lib/src/minio.dart index a1d1f6e..670ddb1 100644 --- a/lib/src/minio.dart +++ b/lib/src/minio.dart @@ -68,15 +68,15 @@ class Minio { /// Checks if a bucket exists. /// - /// Returns `true` if the [bucket] exists or you don't have permission to access - /// it (which implies that it exists). Returns `false` only if the [bucket] does - /// not exist. + /// Returns `true` only if the [bucket] exists and you have the permission + /// to access it. Returns `false` if the [bucket] does not exist or you + /// don't have the permission to access it. Future<bool> bucketExists(String bucket) async { MinioInvalidBucketNameError.check(bucket); try { final response = await _client.request(method: 'HEAD', bucket: bucket); validate(response); - return (response.statusCode == 200 || response.statusCode == 403); + return response.statusCode == 200; } on MinioS3Error catch (e) { final code = e.error.code; if (code == 'NoSuchBucket' || code == 'NotFound' || code == 'Not Found') { -- GitLab