mirror of
https://github.com/minio/minio.git
synced 2024-12-28 08:05:55 -05:00
Merge pull request #424 from fkautz/pr_out_add_partial_object_support_to_donut_driver
This commit is contained in:
commit
e73c3b379f
@ -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…
Reference in New Issue
Block a user