diff --git a/pkg/api/api_test.go b/pkg/api/api_test.go index 135303198..16453c546 100644 --- a/pkg/api/api_test.go +++ b/pkg/api/api_test.go @@ -33,6 +33,7 @@ import ( "github.com/minio-io/minio/pkg/api" "github.com/minio-io/minio/pkg/drivers" + "github.com/minio-io/minio/pkg/drivers/donut" "github.com/minio-io/minio/pkg/drivers/file" "github.com/minio-io/minio/pkg/drivers/memory" "github.com/minio-io/minio/pkg/drivers/mocks" @@ -71,6 +72,14 @@ var _ = Suite(&MySuite{ }, }) +var _ = Suite(&MySuite{ + initDriver: func() (drivers.Driver, string) { + root, _ := ioutil.TempDir(os.TempDir(), "minio-api") + _, _, driver := donut.Start(root) + return driver, root + }, +}) + func (s *MySuite) SetUpSuite(c *C) { driver, root := s.initDriver() if root != "" { diff --git a/pkg/drivers/donut/donut.go b/pkg/drivers/donut/donut.go index c1ceecd7b..c93f527cf 100644 --- a/pkg/drivers/donut/donut.go +++ b/pkg/drivers/donut/donut.go @@ -28,6 +28,7 @@ import ( "github.com/minio-io/minio/pkg/drivers" "github.com/minio-io/minio/pkg/storage/donut" "github.com/minio-io/minio/pkg/utils/log" + "io/ioutil" ) // donutDriver - creates a new single disk drivers driver using donut @@ -112,7 +113,23 @@ func (d donutDriver) GetObject(target io.Writer, bucket, key string) (int64, err // GetPartialObject retrieves an object range and writes it to a writer func (d donutDriver) GetPartialObject(w io.Writer, bucket, object string, start, length int64) (int64, error) { - return 0, errors.New("Not Implemented") + // TODO more efficient get partial object with proper donut support + errParams := map[string]string{ + "bucket": bucket, + "object": object, + "start": strconv.FormatInt(start, 10), + "length": strconv.FormatInt(length, 10), + } + reader, err := d.donut.GetObjectReader(bucket, object) + if err != nil { + return 0, iodine.New(err, errParams) + } + _, err = io.CopyN(ioutil.Discard, reader, start) + if err != nil { + return 0, iodine.New(err, errParams) + } + n, err := io.CopyN(w, reader, length) + return n, iodine.New(err, errParams) } // GetObjectMetadata retrieves an object's metadata