mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
XL: Multipart update uploads.json properly. (#1741)
This commit is contained in:
parent
ed43d5e02b
commit
a00a5c6e7e
@ -77,7 +77,7 @@ func (m *xlMetaV1) ReadFrom(reader io.Reader) (n int64, err error) {
|
||||
|
||||
// WriteTo - write to implements io.WriterTo interface for marshalling xlMetaV1.
|
||||
func (m xlMetaV1) WriteTo(writer io.Writer) (n int64, err error) {
|
||||
metadataBytes, err := json.Marshal(m)
|
||||
metadataBytes, err := json.Marshal(&m)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -231,6 +231,8 @@ func (xl xlObjects) writeXLMetadata(bucket, prefix string, xlMeta xlMetaV1) erro
|
||||
var mErrs = make([]error, len(xl.storageDisks))
|
||||
|
||||
// Initialize metadata map, save all erasure related metadata.
|
||||
xlMeta.Version = "1"
|
||||
xlMeta.Format = "xl"
|
||||
xlMeta.Minio.Release = minioReleaseTag
|
||||
xlMeta.Erasure.DataBlocks = xl.dataBlocks
|
||||
xlMeta.Erasure.ParityBlocks = xl.parityBlocks
|
||||
|
@ -82,7 +82,7 @@ func (u *uploadsV1) ReadFrom(reader io.Reader) (n int64, err error) {
|
||||
|
||||
// WriteTo - write to implements io.WriterTo interface for marshalling uploads.
|
||||
func (u uploadsV1) WriteTo(writer io.Writer) (n int64, err error) {
|
||||
metadataBytes, err := json.Marshal(u)
|
||||
metadataBytes, err := json.Marshal(&u)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -206,15 +206,8 @@ func writeUploadJSON(bucket, object, uploadID string, initiated time.Time, stora
|
||||
errs[index] = wErr
|
||||
return
|
||||
}
|
||||
|
||||
_, wErr = disk.StatFile(minioMetaBucket, uploadsPath)
|
||||
wErr = disk.RenameFile(minioMetaBucket, tmpUploadsPath, minioMetaBucket, uploadsPath)
|
||||
if wErr != nil {
|
||||
if wErr == errFileNotFound {
|
||||
wErr = disk.RenameFile(minioMetaBucket, tmpUploadsPath, minioMetaBucket, uploadsPath)
|
||||
if wErr == nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
if dErr := disk.DeleteFile(minioMetaBucket, tmpUploadsPath); dErr != nil {
|
||||
errs[index] = dErr
|
||||
return
|
||||
@ -222,6 +215,7 @@ func writeUploadJSON(bucket, object, uploadID string, initiated time.Time, stora
|
||||
errs[index] = wErr
|
||||
return
|
||||
}
|
||||
errs[index] = nil
|
||||
}(index, disk)
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,12 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/minio/minio/pkg/mimedb"
|
||||
)
|
||||
|
||||
// ListMultipartUploads - list multipart uploads.
|
||||
@ -54,11 +58,16 @@ func (xl xlObjects) newMultipartUploadCommon(bucket string, object string, meta
|
||||
}
|
||||
|
||||
xlMeta := xlMetaV1{}
|
||||
xlMeta.Format = "xl"
|
||||
xlMeta.Version = "1"
|
||||
// If not set default to "application/octet-stream"
|
||||
if meta["content-type"] == "" {
|
||||
meta["content-type"] = "application/octet-stream"
|
||||
contentType := "application/octet-stream"
|
||||
if objectExt := filepath.Ext(object); objectExt != "" {
|
||||
content, ok := mimedb.DB[strings.ToLower(strings.TrimPrefix(objectExt, "."))]
|
||||
if ok {
|
||||
contentType = content.ContentType
|
||||
}
|
||||
}
|
||||
meta["content-type"] = contentType
|
||||
}
|
||||
xlMeta.Meta = meta
|
||||
|
||||
|
@ -280,8 +280,6 @@ func (xl xlObjects) PutObject(bucket string, object string, size int64, data io.
|
||||
}
|
||||
|
||||
xlMeta := xlMetaV1{}
|
||||
xlMeta.Version = "1"
|
||||
xlMeta.Format = "xl"
|
||||
xlMeta.Meta = metadata
|
||||
xlMeta.Stat.Size = size
|
||||
xlMeta.Stat.ModTime = modTime
|
||||
|
Loading…
Reference in New Issue
Block a user