Store in json file instead of gob for fs metadata

This commit is contained in:
Harshavardhana 2015-06-08 12:08:01 -07:00
parent 50994d7d71
commit 0d3710cb9b
2 changed files with 15 additions and 15 deletions

View File

@ -5,8 +5,8 @@ import (
"crypto/md5"
"crypto/sha512"
"encoding/base64"
"encoding/gob"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"io"
@ -73,7 +73,7 @@ func (fs *fsDriver) ListMultipartUploads(bucket string, resources drivers.Bucket
defer activeSessionFile.Close()
var deserializedActiveSession map[string]*MultipartSession
decoder := gob.NewDecoder(activeSessionFile)
decoder := json.NewDecoder(activeSessionFile)
err = decoder.Decode(&deserializedActiveSession)
if 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
fs.multiparts.ActiveSession[key] = mpartSession
encoder := gob.NewEncoder(file)
encoder := json.NewEncoder(file)
err = encoder.Encode(mpartSession)
if err != nil {
return "", iodine.New(err, nil)
}
encoder = gob.NewEncoder(activeSessionFile)
encoder = json.NewEncoder(activeSessionFile)
err = encoder.Encode(fs.multiparts.ActiveSession)
if 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()
var deserializedMultipartSession MultipartSession
decoder := gob.NewDecoder(multiPartfile)
decoder := json.NewDecoder(multiPartfile)
err = decoder.Decode(&deserializedMultipartSession)
if 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
sort.Sort(partNumber(deserializedMultipartSession.Parts))
encoder := gob.NewEncoder(multiPartfile)
encoder := json.NewEncoder(multiPartfile)
err = encoder.Encode(&deserializedMultipartSession)
if err != nil {
return "", iodine.New(err, nil)
@ -447,8 +447,8 @@ func (fs *fsDriver) CompleteMultipartUpload(bucket, key, uploadID string, parts
ContentType: "application/octet-stream",
Md5sum: h.Sum(nil),
}
// serialize metadata to gob
encoder := gob.NewEncoder(file)
// serialize metadata to json
encoder := json.NewEncoder(file)
err = encoder.Encode(metadata)
if 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)
}
defer activeSessionFile.Close()
encoder = gob.NewEncoder(activeSessionFile)
encoder = json.NewEncoder(activeSessionFile)
err = encoder.Encode(fs.multiparts.ActiveSession)
if err != nil {
return "", iodine.New(err, nil)
@ -514,7 +514,7 @@ func (fs *fsDriver) ListObjectParts(bucket, key string, resources drivers.Object
defer multiPartfile.Close()
var deserializedMultipartSession MultipartSession
decoder := gob.NewDecoder(multiPartfile)
decoder := json.NewDecoder(multiPartfile)
err = decoder.Decode(&deserializedMultipartSession)
if 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
decoder := gob.NewDecoder(multiPartfile)
decoder := json.NewDecoder(multiPartfile)
err = decoder.Decode(&deserializedMultipartSession)
if err != nil {
return iodine.New(err, nil)

View File

@ -25,8 +25,8 @@ import (
"crypto/md5"
"encoding/base64"
"encoding/gob"
"encoding/hex"
"encoding/json"
"errors"
"github.com/minio/minio/pkg/iodine"
@ -154,7 +154,7 @@ func (fs *fsDriver) GetObjectMetadata(bucket, object string) (drivers.ObjectMeta
}
var deserializedMetadata Metadata
decoder := gob.NewDecoder(file)
decoder := json.NewDecoder(file)
err = decoder.Decode(&deserializedMetadata)
if err != nil {
return drivers.ObjectMetadata{}, iodine.New(err, nil)
@ -280,8 +280,8 @@ func (fs *fsDriver) CreateObject(bucket, key, contentType, expectedMD5Sum string
ContentType: contentType,
Md5sum: h.Sum(nil),
}
// serialize metadata to gob
encoder := gob.NewEncoder(file)
// serialize metadata to json
encoder := json.NewEncoder(file)
err = encoder.Encode(metadata)
md5Sum := hex.EncodeToString(metadata.Md5sum)