feat(storage): 为 Minio 存储添加版本检查跳过选项

pull/33166/head
xiandan 3 weeks ago
parent 88366f280e
commit 0f6acdb1fd
  1. 1
      modules/setting/storage.go
  2. 4
      modules/storage/minio.go

@ -52,6 +52,7 @@ type MinioStorageConfig struct {
ChecksumAlgorithm string `ini:"MINIO_CHECKSUM_ALGORITHM" json:",omitempty"` ChecksumAlgorithm string `ini:"MINIO_CHECKSUM_ALGORITHM" json:",omitempty"`
ServeDirect bool `ini:"SERVE_DIRECT"` ServeDirect bool `ini:"SERVE_DIRECT"`
BucketLookUpType string `ini:"MINIO_BUCKET_LOOKUP_TYPE" json:",omitempty"` BucketLookUpType string `ini:"MINIO_BUCKET_LOOKUP_TYPE" json:",omitempty"`
SkipVersionCheck bool `ini:"SKIP_VERSION_CHECK" json:",omitempty"`
} }
func (cfg *MinioStorageConfig) ToShadow() { func (cfg *MinioStorageConfig) ToShadow() {

@ -112,7 +112,9 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage,
// Otherwise even if the request itself fails (403, 404, etc), the code should still continue because the parameters seem "good" enough. // Otherwise even if the request itself fails (403, 404, etc), the code should still continue because the parameters seem "good" enough.
// Keep in mind that GetBucketVersioning requires "owner" to really succeed, so it can't be used to check the existence. // Keep in mind that GetBucketVersioning requires "owner" to really succeed, so it can't be used to check the existence.
// Not using "BucketExists (HeadBucket)" because it doesn't include detailed failure reasons. // Not using "BucketExists (HeadBucket)" because it doesn't include detailed failure reasons.
err = getBucketVersioning(ctx, minioClient, config.Bucket) if !config.SkipVersionCheck {
err = getBucketVersioning(ctx, minioClient, config.Bucket)
}
if err != nil { if err != nil {
errResp, ok := err.(minio.ErrorResponse) errResp, ok := err.(minio.ErrorResponse)
if !ok { if !ok {

Loading…
Cancel
Save