From bfbcd5a3d98b958fd3b4667a24811ad9299e920e Mon Sep 17 00:00:00 2001 From: zhijian Date: Fri, 12 Apr 2024 15:52:23 +0800 Subject: [PATCH] delete bucket metadata when deleting a bucket. --- go.mod | 2 +- go.sum | 4 ++-- pkg/gateway/gateway.go | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 633048779f6a..bdcc28661311 100644 --- a/go.mod +++ b/go.mod @@ -245,7 +245,7 @@ require ( xorm.io/builder v0.3.7 // indirect ) -replace github.com/minio/minio v0.0.0-20210206053228-97fe57bba92c => github.com/juicedata/minio v0.0.0-20240408095715-fb94ff5aa81f +replace github.com/minio/minio v0.0.0-20210206053228-97fe57bba92c => github.com/juicedata/minio v0.0.0-20240412074428-6fa8baf7e06c replace github.com/hanwen/go-fuse/v2 v2.1.1-0.20210611132105-24a1dfe6b4f8 => github.com/juicedata/go-fuse/v2 v2.1.1-0.20240202080323-002ef792942e diff --git a/go.sum b/go.sum index 3f02e22bcc20..15769cfb130e 100644 --- a/go.sum +++ b/go.sum @@ -507,8 +507,8 @@ github.com/juicedata/gogfapi v0.0.0-20230626071140-fc28e5537825 h1:7KrwI4HPqvNLK github.com/juicedata/gogfapi v0.0.0-20230626071140-fc28e5537825/go.mod h1:Ho5G4KgrgbMKW0buAJdOmYoJcOImkzznJQaLiATrsx4= github.com/juicedata/huaweicloud-sdk-go-obs v3.22.12-0.20230228031208-386e87b5c091+incompatible h1:2/ttSmYoX+QMegpNyAJR0Y6aHcVk57F7RJit5xN2T/s= github.com/juicedata/huaweicloud-sdk-go-obs v3.22.12-0.20230228031208-386e87b5c091+incompatible/go.mod h1:Ukwa8ffRQLV6QRwpqGioPjn2Wnf7TBDA4DbennDOqHE= -github.com/juicedata/minio v0.0.0-20240408095715-fb94ff5aa81f h1:CQxx8xzZLoQ8UEJFvowmPK01ojUXs4mqI6okGIYCMqE= -github.com/juicedata/minio v0.0.0-20240408095715-fb94ff5aa81f/go.mod h1:UOWyfa3ls1tnpJrNw2yzGqfrwM4nzsZq/qz+zd6H+/Q= +github.com/juicedata/minio v0.0.0-20240412074428-6fa8baf7e06c h1:31cU5yupOAL1ZtTz3iMjdVqJuB395EXy7jUSk27wqqo= +github.com/juicedata/minio v0.0.0-20240412074428-6fa8baf7e06c/go.mod h1:UOWyfa3ls1tnpJrNw2yzGqfrwM4nzsZq/qz+zd6H+/Q= github.com/juicedata/mpb/v7 v7.0.4-0.20231024073412-2b8d31be510b h1:0/6suPNZnrOlRlBaU/Bnitu8HiKkkLSzQhHbwQ9AysM= github.com/juicedata/mpb/v7 v7.0.4-0.20231024073412-2b8d31be510b/go.mod h1:NXGsfPGx6G2JssqvEcULtDqUrxuuYs4llpv8W6ZUpzk= github.com/juju/ratelimit v1.0.2 h1:sRxmtRiajbvrcLQT7S+JbqU0ntsb9W2yhSdNN8tWfaI= diff --git a/pkg/gateway/gateway.go b/pkg/gateway/gateway.go index 86c50aa48ea4..2e41ecbbd64d 100644 --- a/pkg/gateway/gateway.go +++ b/pkg/gateway/gateway.go @@ -200,6 +200,10 @@ func (n *jfsObjects) DeleteBucket(ctx context.Context, bucket string, forceDelet if !n.gConf.MultiBucket { return minio.BucketNotEmpty{Bucket: bucket} } + if eno := n.fs.Delete(mctx, n.path(minio.MinioMetaBucket, minio.BucketMetaPrefix, bucket, minio.BucketMetadataFile)); eno != 0 { + logger.Errorf("delete bucket metadata: %s", eno) + } + _ = n.fs.Delete(mctx, n.path(minio.MinioMetaBucket, minio.BucketMetaPrefix, bucket)) eno := n.fs.Delete(mctx, n.path(bucket)) return jfsToObjectErr(ctx, eno, bucket) } @@ -214,6 +218,10 @@ func (n *jfsObjects) MakeBucketWithLocation(ctx context.Context, bucket string, } } eno := n.fs.Mkdir(mctx, n.path(bucket), 0777, n.gConf.Umask) + metadata := minio.NewBucketMetadata(bucket) + if err := metadata.Save(ctx, n); err != nil { + return err + } return jfsToObjectErr(ctx, eno, bucket) }