mirror of https://github.com/minio/minio.git
Store in json file instead of gob for fs metadata
This commit is contained in:
parent
50994d7d71
commit
0d3710cb9b
|
@ -5,8 +5,8 @@ import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"crypto/sha512"
|
"crypto/sha512"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/gob"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
@ -73,7 +73,7 @@ func (fs *fsDriver) ListMultipartUploads(bucket string, resources drivers.Bucket
|
||||||
defer activeSessionFile.Close()
|
defer activeSessionFile.Close()
|
||||||
|
|
||||||
var deserializedActiveSession map[string]*MultipartSession
|
var deserializedActiveSession map[string]*MultipartSession
|
||||||
decoder := gob.NewDecoder(activeSessionFile)
|
decoder := json.NewDecoder(activeSessionFile)
|
||||||
err = decoder.Decode(&deserializedActiveSession)
|
err = decoder.Decode(&deserializedActiveSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return drivers.BucketMultipartResourcesMetadata{}, iodine.New(err, nil)
|
return drivers.BucketMultipartResourcesMetadata{}, iodine.New(err, nil)
|
||||||
|
@ -192,12 +192,12 @@ func (fs *fsDriver) NewMultipartUpload(bucket, key, contentType string) (string,
|
||||||
mpartSession.Parts = parts
|
mpartSession.Parts = parts
|
||||||
fs.multiparts.ActiveSession[key] = mpartSession
|
fs.multiparts.ActiveSession[key] = mpartSession
|
||||||
|
|
||||||
encoder := gob.NewEncoder(file)
|
encoder := json.NewEncoder(file)
|
||||||
err = encoder.Encode(mpartSession)
|
err = encoder.Encode(mpartSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", iodine.New(err, nil)
|
return "", iodine.New(err, nil)
|
||||||
}
|
}
|
||||||
encoder = gob.NewEncoder(activeSessionFile)
|
encoder = json.NewEncoder(activeSessionFile)
|
||||||
err = encoder.Encode(fs.multiparts.ActiveSession)
|
err = encoder.Encode(fs.multiparts.ActiveSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", iodine.New(err, nil)
|
return "", iodine.New(err, nil)
|
||||||
|
@ -329,7 +329,7 @@ func (fs *fsDriver) CreateObjectPart(bucket, key, uploadID string, partID int, c
|
||||||
defer multiPartfile.Close()
|
defer multiPartfile.Close()
|
||||||
|
|
||||||
var deserializedMultipartSession MultipartSession
|
var deserializedMultipartSession MultipartSession
|
||||||
decoder := gob.NewDecoder(multiPartfile)
|
decoder := json.NewDecoder(multiPartfile)
|
||||||
err = decoder.Decode(&deserializedMultipartSession)
|
err = decoder.Decode(&deserializedMultipartSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", iodine.New(err, nil)
|
return "", iodine.New(err, nil)
|
||||||
|
@ -339,7 +339,7 @@ func (fs *fsDriver) CreateObjectPart(bucket, key, uploadID string, partID int, c
|
||||||
fs.multiparts.ActiveSession[uploadID] = &deserializedMultipartSession
|
fs.multiparts.ActiveSession[uploadID] = &deserializedMultipartSession
|
||||||
|
|
||||||
sort.Sort(partNumber(deserializedMultipartSession.Parts))
|
sort.Sort(partNumber(deserializedMultipartSession.Parts))
|
||||||
encoder := gob.NewEncoder(multiPartfile)
|
encoder := json.NewEncoder(multiPartfile)
|
||||||
err = encoder.Encode(&deserializedMultipartSession)
|
err = encoder.Encode(&deserializedMultipartSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", iodine.New(err, nil)
|
return "", iodine.New(err, nil)
|
||||||
|
@ -447,8 +447,8 @@ func (fs *fsDriver) CompleteMultipartUpload(bucket, key, uploadID string, parts
|
||||||
ContentType: "application/octet-stream",
|
ContentType: "application/octet-stream",
|
||||||
Md5sum: h.Sum(nil),
|
Md5sum: h.Sum(nil),
|
||||||
}
|
}
|
||||||
// serialize metadata to gob
|
// serialize metadata to json
|
||||||
encoder := gob.NewEncoder(file)
|
encoder := json.NewEncoder(file)
|
||||||
err = encoder.Encode(metadata)
|
err = encoder.Encode(metadata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", iodine.New(err, nil)
|
return "", iodine.New(err, nil)
|
||||||
|
@ -459,7 +459,7 @@ func (fs *fsDriver) CompleteMultipartUpload(bucket, key, uploadID string, parts
|
||||||
return "", iodine.New(err, nil)
|
return "", iodine.New(err, nil)
|
||||||
}
|
}
|
||||||
defer activeSessionFile.Close()
|
defer activeSessionFile.Close()
|
||||||
encoder = gob.NewEncoder(activeSessionFile)
|
encoder = json.NewEncoder(activeSessionFile)
|
||||||
err = encoder.Encode(fs.multiparts.ActiveSession)
|
err = encoder.Encode(fs.multiparts.ActiveSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", iodine.New(err, nil)
|
return "", iodine.New(err, nil)
|
||||||
|
@ -514,7 +514,7 @@ func (fs *fsDriver) ListObjectParts(bucket, key string, resources drivers.Object
|
||||||
defer multiPartfile.Close()
|
defer multiPartfile.Close()
|
||||||
|
|
||||||
var deserializedMultipartSession MultipartSession
|
var deserializedMultipartSession MultipartSession
|
||||||
decoder := gob.NewDecoder(multiPartfile)
|
decoder := json.NewDecoder(multiPartfile)
|
||||||
err = decoder.Decode(&deserializedMultipartSession)
|
err = decoder.Decode(&deserializedMultipartSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return drivers.ObjectResourcesMetadata{}, iodine.New(err, nil)
|
return drivers.ObjectResourcesMetadata{}, iodine.New(err, nil)
|
||||||
|
@ -570,7 +570,7 @@ func (fs *fsDriver) AbortMultipartUpload(bucket, key, uploadID string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var deserializedMultipartSession MultipartSession
|
var deserializedMultipartSession MultipartSession
|
||||||
decoder := gob.NewDecoder(multiPartfile)
|
decoder := json.NewDecoder(multiPartfile)
|
||||||
err = decoder.Decode(&deserializedMultipartSession)
|
err = decoder.Decode(&deserializedMultipartSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return iodine.New(err, nil)
|
return iodine.New(err, nil)
|
||||||
|
|
|
@ -25,8 +25,8 @@ import (
|
||||||
|
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/gob"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/minio/minio/pkg/iodine"
|
"github.com/minio/minio/pkg/iodine"
|
||||||
|
@ -154,7 +154,7 @@ func (fs *fsDriver) GetObjectMetadata(bucket, object string) (drivers.ObjectMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
var deserializedMetadata Metadata
|
var deserializedMetadata Metadata
|
||||||
decoder := gob.NewDecoder(file)
|
decoder := json.NewDecoder(file)
|
||||||
err = decoder.Decode(&deserializedMetadata)
|
err = decoder.Decode(&deserializedMetadata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return drivers.ObjectMetadata{}, iodine.New(err, nil)
|
return drivers.ObjectMetadata{}, iodine.New(err, nil)
|
||||||
|
@ -280,8 +280,8 @@ func (fs *fsDriver) CreateObject(bucket, key, contentType, expectedMD5Sum string
|
||||||
ContentType: contentType,
|
ContentType: contentType,
|
||||||
Md5sum: h.Sum(nil),
|
Md5sum: h.Sum(nil),
|
||||||
}
|
}
|
||||||
// serialize metadata to gob
|
// serialize metadata to json
|
||||||
encoder := gob.NewEncoder(file)
|
encoder := json.NewEncoder(file)
|
||||||
err = encoder.Encode(metadata)
|
err = encoder.Encode(metadata)
|
||||||
|
|
||||||
md5Sum := hex.EncodeToString(metadata.Md5sum)
|
md5Sum := hex.EncodeToString(metadata.Md5sum)
|
||||||
|
|
Loading…
Reference in New Issue