Fix issues with multipart upload

This commit is contained in:
Harshavardhana
2015-07-06 16:18:39 -07:00
parent 474954022e
commit 8b94c53345
4 changed files with 26 additions and 19 deletions

View File

@@ -85,8 +85,6 @@ func (r *Cache) SetMaxSize(maxSize uint64) {
// Stats get current cache statistics
func (r *Cache) Stats() Stats {
r.Lock()
defer r.Unlock()
return Stats{
Bytes: r.currentSize,
Items: r.items.Len(),

View File

@@ -113,7 +113,12 @@ func New() (Interface, error) {
return nil, iodine.New(err, nil)
}
for k, v := range buckets {
a.storedBuckets.Set(k, v)
var newBucket = storedBucket{}
newBucket.objectMetadata = make(map[string]ObjectMetadata)
newBucket.multiPartSession = make(map[string]MultiPartSession)
newBucket.partMetadata = make(map[int]PartMetadata)
newBucket.bucketMetadata = v
a.storedBuckets.Set(k, newBucket)
}
}
return a, nil

View File

@@ -22,6 +22,8 @@ import (
"encoding/base64"
"encoding/hex"
"io/ioutil"
"os"
"path/filepath"
"testing"
. "github.com/minio/check"
@@ -29,13 +31,20 @@ import (
func TestCache(t *testing.T) { TestingT(t) }
type MyCacheSuite struct{}
type MyCacheSuite struct {
root string
}
var _ = Suite(&MyCacheSuite{})
var dc Interface
func (s *MyCacheSuite) SetUpSuite(c *C) {
root, err := ioutil.TempDir(os.TempDir(), "donut-")
c.Assert(err, IsNil)
s.root = root
customConfigPath = filepath.Join(root, "donut.json")
var err error
dc, err = New()
c.Assert(err, IsNil)
@@ -46,6 +55,10 @@ func (s *MyCacheSuite) SetUpSuite(c *C) {
c.Assert(len(buckets), Equals, 0)
}
func (s *MyDonutSuite) TearDownSuite(c *C) {
os.RemoveAll(s.root)
}
// test make bucket without name
func (s *MyCacheSuite) TestBucketWithoutNameFails(c *C) {
// fail to create new bucket without a name