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