mirror of https://github.com/go-gitea/gitea.git
Update minio.go
This commit is contained in:
parent
570abd2fcc
commit
635e997e50
|
@ -50,7 +50,6 @@ type MinioStorage struct {
|
|||
client *minio.Client
|
||||
bucket string
|
||||
basePath string
|
||||
config *MinioStorageConfig
|
||||
}
|
||||
|
||||
func convertMinioErr(err error) error {
|
||||
|
@ -112,7 +111,6 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage,
|
|||
client: minioClient,
|
||||
bucket: config.Bucket,
|
||||
basePath: config.BasePath,
|
||||
config: &config,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -137,8 +135,8 @@ func (m *MinioStorage) Open(path string) (Object, error) {
|
|||
// Save saves a file to minio
|
||||
func (m *MinioStorage) Save(path string, r io.Reader, size int64) (int64, error) {
|
||||
disableSignature, disableMultipart := false, false
|
||||
if m.config != nil {
|
||||
disableSignature, disableMultipart = m.config.DisableSignature, m.config.DisableMultipart
|
||||
if m.cfg != nil {
|
||||
disableSignature, disableMultipart = m.cfg.DisableSignature, m.cfg.DisableMultipart
|
||||
}
|
||||
|
||||
if disableMultipart && size < 0 {
|
||||
|
@ -146,6 +144,8 @@ func (m *MinioStorage) Save(path string, r io.Reader, size int64) (int64, error)
|
|||
// but since we have disabled multipart upload this mean we can't really stream write anymore...
|
||||
// well, unless we have a better way to estimate the stream size, this would be a workaround
|
||||
|
||||
// another alternative: we can use mmap instead, but this would be very dangerous as it is platform-specific
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
n, err := io.Copy(buf, r)
|
||||
if err != nil {
|
||||
|
@ -171,8 +171,8 @@ func (m *MinioStorage) Save(path string, r io.Reader, size int64) (int64, error)
|
|||
// * https://www.backblaze.com/b2/docs/s3_compatible_api.html
|
||||
// do not support "x-amz-checksum-algorithm" header, so use legacy MD5 checksum
|
||||
SendContentMd5: m.cfg.ChecksumAlgorithm == "md5",
|
||||
DisableContentSha256: m.cfg.DisableSignature,
|
||||
DisableMultipart: m.cfg.DisableMultipart
|
||||
DisableContentSha256: disableSignature,
|
||||
DisableMultipart: disableMultipart
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue