mirror of https://github.com/minio/minio.git
storage.ObjectStorage List() is now List(objectPath string)
This commit is contained in:
parent
16e92521bd
commit
5efc0d54f8
|
@ -11,14 +11,14 @@ import (
|
||||||
es "github.com/minio-io/minio/pkgs/storage/encodedstorage"
|
es "github.com/minio-io/minio/pkgs/storage/encodedstorage"
|
||||||
)
|
)
|
||||||
|
|
||||||
func erasureGetList(config inputConfig) (io.Reader, error) {
|
func erasureGetList(config inputConfig, objectPath string) (io.Reader, error) {
|
||||||
var objectStorage storage.ObjectStorage
|
var objectStorage storage.ObjectStorage
|
||||||
rootDir := path.Join(config.rootDir, config.storageDriver)
|
rootDir := path.Join(config.rootDir, config.storageDriver)
|
||||||
objectStorage, err := es.NewStorage(rootDir, config.k, config.m, config.blockSize)
|
objectStorage, err := es.NewStorage(rootDir, config.k, config.m, config.blockSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
objectDescList, err := objectStorage.List()
|
objectDescList, err := objectStorage.List(objectPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ func get(c *cli.Context) {
|
||||||
case "erasure":
|
case "erasure":
|
||||||
{
|
{
|
||||||
if len(objectName) == 0 {
|
if len(objectName) == 0 {
|
||||||
if objectReader, err = erasureGetList(config); err != nil {
|
if objectReader, err = erasureGetList(config, ""); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/minio-io/minio/pkgs/checksum/crc32c"
|
"github.com/minio-io/minio/pkgs/checksum/crc32c"
|
||||||
"github.com/minio-io/minio/pkgs/storage"
|
"github.com/minio-io/minio/pkgs/storage"
|
||||||
|
@ -133,15 +134,17 @@ func (aStorage *appendStorage) Put(objectPath string, object io.Reader) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (aStorage *appendStorage) List() ([]storage.ObjectDescription, error) {
|
func (aStorage *appendStorage) List(objectPath string) ([]storage.ObjectDescription, error) {
|
||||||
var objectDescList []storage.ObjectDescription
|
var objectDescList []storage.ObjectDescription
|
||||||
for objectName, _ := range aStorage.objects {
|
for objectName, _ := range aStorage.objects {
|
||||||
|
if strings.HasPrefix(objectName, objectPath) {
|
||||||
var objectDescription storage.ObjectDescription
|
var objectDescription storage.ObjectDescription
|
||||||
objectDescription.Name = objectName
|
objectDescription.Name = objectName
|
||||||
objectDescription.Md5sum = ""
|
objectDescription.Md5sum = ""
|
||||||
objectDescription.Murmur3 = ""
|
objectDescription.Murmur3 = ""
|
||||||
objectDescList = append(objectDescList, objectDescription)
|
objectDescList = append(objectDescList, objectDescription)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(objectDescList) == 0 {
|
if len(objectDescList) == 0 {
|
||||||
return nil, errors.New("No objects found")
|
return nil, errors.New("No objects found")
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/minio-io/minio/pkgs/erasure"
|
"github.com/minio-io/minio/pkgs/erasure"
|
||||||
"github.com/minio-io/minio/pkgs/split"
|
"github.com/minio-io/minio/pkgs/split"
|
||||||
|
@ -116,16 +117,17 @@ func (eStorage *encodedStorage) Get(objectPath string) (io.Reader, error) {
|
||||||
return reader, nil
|
return reader, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eStorage *encodedStorage) List() ([]storage.ObjectDescription, error) {
|
func (eStorage *encodedStorage) List(objectPath string) ([]storage.ObjectDescription, error) {
|
||||||
var objectDescList []storage.ObjectDescription
|
var objectDescList []storage.ObjectDescription
|
||||||
for objectName, objectEntry := range eStorage.objects {
|
for objectName, objectEntry := range eStorage.objects {
|
||||||
|
if strings.HasPrefix(objectName, objectPath) {
|
||||||
var objectDescription storage.ObjectDescription
|
var objectDescription storage.ObjectDescription
|
||||||
//protectionLevel := strconv.Itoa(objectEntry.Encoderparams.K) + "," + strconv.Itoa(objectEntry.Encoderparams.M)
|
|
||||||
objectDescription.Name = objectName
|
objectDescription.Name = objectName
|
||||||
objectDescription.Md5sum = hex.EncodeToString(objectEntry.Md5sum)
|
objectDescription.Md5sum = hex.EncodeToString(objectEntry.Md5sum)
|
||||||
objectDescription.Murmur3 = strconv.FormatUint(objectEntry.Murmurhash, 16)
|
objectDescription.Murmur3 = strconv.FormatUint(objectEntry.Murmurhash, 16)
|
||||||
objectDescList = append(objectDescList, objectDescription)
|
objectDescList = append(objectDescList, objectDescription)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(objectDescList) == 0 {
|
if len(objectDescList) == 0 {
|
||||||
return nil, errors.New("No objects found")
|
return nil, errors.New("No objects found")
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ func (s *EncodedStorageSuite) TestFileStoragePutAtRootPath(c *C) {
|
||||||
object1, _ := ioutil.ReadAll(objectResult1)
|
object1, _ := ioutil.ReadAll(objectResult1)
|
||||||
c.Assert(string(object1), Equals, "object1")
|
c.Assert(string(object1), Equals, "object1")
|
||||||
|
|
||||||
objectList, err := objectStorage.List()
|
objectList, err := objectStorage.List("")
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert(objectList[0].Name, Equals, "path1")
|
c.Assert(objectList[0].Name, Equals, "path1")
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package storage
|
||||||
import "io"
|
import "io"
|
||||||
|
|
||||||
type ObjectStorage interface {
|
type ObjectStorage interface {
|
||||||
List() ([]ObjectDescription, error)
|
List(objectPath string) ([]ObjectDescription, error)
|
||||||
Get(path string) (io.Reader, error)
|
Get(path string) (io.Reader, error)
|
||||||
Put(path string, object io.Reader) error
|
Put(path string, object io.Reader) error
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue