]> source.dussan.org Git - gitea.git/commitdiff
Use correct minio error (#26634) (#26639)
authorGiteabot <teabot@gitea.io>
Mon, 21 Aug 2023 16:51:30 +0000 (00:51 +0800)
committerGitHub <noreply@github.com>
Mon, 21 Aug 2023 16:51:30 +0000 (16:51 +0000)
Backport #26634 by @delvh

Previously, `err` was defined above, checked for `err == nil` and used
nowhere else.
Hence, the result of `convertMinioErr` would always be `nil`.
This leads to a NPE further down the line.
That is not intentional, it should convert the error of the most recent
operation, not one of its predecessors.

Found through
https://discord.com/channels/322538954119184384/322538954119184384/1143185780206993550.

Co-authored-by: delvh <dev.lh@web.de>
modules/storage/minio.go

index f50f341022c616a429180e03bc19d75556aa092d..3246993bb1ceddb33a034b8322f924029a25136e 100644 (file)
@@ -91,8 +91,8 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage,
        }
 
        // Check to see if we already own this bucket
-       exists, errBucketExists := minioClient.BucketExists(ctx, config.Bucket)
-       if errBucketExists != nil {
+       exists, err := minioClient.BucketExists(ctx, config.Bucket)
+       if err != nil {
                return nil, convertMinioErr(err)
        }