Merge pull request #314 from fkautz/pr_out_encoded_now_passes_tests_enabling

master
Frederick F. Kautz IV 10 years ago
commit 6070d18217
  1. 4
      pkg/donutbox/donutmem/donutmem.go
  2. 24
      pkg/storage/encoded/encoded.go

@ -8,6 +8,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"time"
) )
type bucket struct { type bucket struct {
@ -58,6 +59,7 @@ func (donutMem donutMem) CreateBucket(b string) error {
} }
metadata := make(map[string]string) metadata := make(map[string]string)
metadata["name"] = b metadata["name"] = b
metadata["created"] = time.Now().Format(time.RFC3339Nano)
newBucket := bucket{ newBucket := bucket{
name: b, name: b,
metadata: metadata, metadata: metadata,
@ -234,7 +236,7 @@ func (donutMem donutMem) GetObjectMetadata(bucketKey, objectKey string, column u
} }
return result, nil return result, nil
} }
return nil, errors.New("Object not found") return nil, errors.New("Object not Found: " + bucketKey + "#" + objectKey)
} }
return nil, errors.New("Bucket not found") return nil, errors.New("Bucket not found")
} }

@ -62,21 +62,29 @@ func start(ctrlChannel <-chan string, errorChannel chan<- error, s *StorageDrive
} }
// ListBuckets returns a list of buckets // ListBuckets returns a list of buckets
func (diskStorage StorageDriver) ListBuckets() ([]storage.BucketMetadata, error) { func (diskStorage StorageDriver) ListBuckets() (results []storage.BucketMetadata, err error) {
buckets, err := diskStorage.donutBox.ListBuckets() buckets, err := diskStorage.donutBox.ListBuckets()
if err != nil { if err != nil {
return nil, err return nil, err
} }
var results []storage.BucketMetadata
sort.Strings(buckets) sort.Strings(buckets)
for _, bucket := range buckets { for _, bucket := range buckets {
bucketMetadata, err := diskStorage.GetBucketMetadata(bucket) metadata, err := diskStorage.donutBox.GetBucketMetadata(bucket)
if err != nil {
return nil, err
}
created, err := time.Parse(time.RFC3339Nano, metadata["created"])
if err != nil { if err != nil {
return nil, err return nil, err
} }
bucketMetadata := storage.BucketMetadata{
Name: bucket,
Created: created,
}
results = append(results, bucketMetadata) results = append(results, bucketMetadata)
} }
return results, nil return results, err
} }
// CreateBucket creates a new bucket // CreateBucket creates a new bucket
@ -124,7 +132,8 @@ func (diskStorage StorageDriver) GetBucketPolicy(bucket string) (storage.BucketP
// GetObject retrieves an object and writes it to a writer // GetObject retrieves an object and writes it to a writer
func (diskStorage StorageDriver) GetObject(target io.Writer, bucket, key string) (int64, error) { func (diskStorage StorageDriver) GetObject(target io.Writer, bucket, key string) (int64, error) {
metadata, err := diskStorage.donutBox.GetObjectMetadata(bucket, key, 0) metadata, err := diskStorage.donutBox.GetObjectMetadata(bucket, key, 0)
if len(metadata) == 0 { if err != nil {
// TODO strongly type and properly handle error cases
return 0, storage.ObjectNotFound{Bucket: bucket, Object: key} return 0, storage.ObjectNotFound{Bucket: bucket, Object: key}
} }
k, err := strconv.Atoi(metadata["erasureK"]) k, err := strconv.Atoi(metadata["erasureK"])
@ -282,6 +291,11 @@ func beforeDelimiter(inputs []string, delim string) (results []string) {
// CreateObject creates a new object // CreateObject creates a new object
func (diskStorage StorageDriver) CreateObject(bucketKey string, objectKey string, contentType string, reader io.Reader) error { func (diskStorage StorageDriver) CreateObject(bucketKey string, objectKey string, contentType string, reader io.Reader) error {
// set defaults
if contentType == "" {
contentType = "application/octet-stream"
}
contentType = strings.TrimSpace(contentType)
// split stream // split stream
splitStream := split.Stream(reader, uint64(blockSize)) splitStream := split.Stream(reader, uint64(blockSize))
writers := make([]*donutbox.NewObject, 16) writers := make([]*donutbox.NewObject, 16)

Loading…
Cancel
Save