Add partial object support to donut driver

master
Frederick F. Kautz IV 10 years ago
parent 27d4893a7e
commit 0c5ed6f3ba
  1. 9
      pkg/api/api_test.go
  2. 19
      pkg/drivers/donut/donut.go

@ -33,6 +33,7 @@ import (
"github.com/minio-io/minio/pkg/api" "github.com/minio-io/minio/pkg/api"
"github.com/minio-io/minio/pkg/drivers" "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/file"
"github.com/minio-io/minio/pkg/drivers/memory" "github.com/minio-io/minio/pkg/drivers/memory"
"github.com/minio-io/minio/pkg/drivers/mocks" "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) { func (s *MySuite) SetUpSuite(c *C) {
driver, root := s.initDriver() driver, root := s.initDriver()
if root != "" { if root != "" {

@ -28,6 +28,7 @@ import (
"github.com/minio-io/minio/pkg/drivers" "github.com/minio-io/minio/pkg/drivers"
"github.com/minio-io/minio/pkg/storage/donut" "github.com/minio-io/minio/pkg/storage/donut"
"github.com/minio-io/minio/pkg/utils/log" "github.com/minio-io/minio/pkg/utils/log"
"io/ioutil"
) )
// donutDriver - creates a new single disk drivers driver using donut // 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 // 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) { 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 // GetObjectMetadata retrieves an object's metadata

Loading…
Cancel
Save