mirror of
https://github.com/minio/minio.git
synced 2025-01-12 23:43:22 -05:00
Merge pull request #768 from harshavardhana/pr_out_listobjects_now_considers_multipart_objects_also_move_to_upstream_check_v1
ListObjects now considers multipart objects, also move to upstream check.v1
This commit is contained in:
commit
3b9043c2ac
10
Godeps/Godeps.json
generated
10
Godeps/Godeps.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ImportPath": "github.com/minio/minio",
|
"ImportPath": "github.com/minio/minio",
|
||||||
"GoVersion": "go1.4",
|
"GoVersion": "go1.4.2",
|
||||||
"Packages": [
|
"Packages": [
|
||||||
"./..."
|
"./..."
|
||||||
],
|
],
|
||||||
@ -37,14 +37,14 @@
|
|||||||
"ImportPath": "github.com/gorilla/rpc/v2",
|
"ImportPath": "github.com/gorilla/rpc/v2",
|
||||||
"Rev": "f6dbf92d77c723632269bf29154cc91f2507693b"
|
"Rev": "f6dbf92d77c723632269bf29154cc91f2507693b"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"ImportPath": "github.com/minio/check",
|
|
||||||
"Rev": "67f8c16c6c27bb03c82e41c2be533ace00035ab4"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/minio/cli",
|
"ImportPath": "github.com/minio/cli",
|
||||||
"Comment": "1.2.0-112-g823349c",
|
"Comment": "1.2.0-112-g823349c",
|
||||||
"Rev": "823349ce91e76834a4af0119d5bbc58fd4d2c6b0"
|
"Rev": "823349ce91e76834a4af0119d5bbc58fd4d2c6b0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "gopkg.in/check.v1",
|
||||||
|
"Rev": "64131543e7896d5bcc6bd5a76287eb75ea96c673"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
110
Godeps/_workspace/src/github.com/minio/check/printer_test.go
generated
vendored
110
Godeps/_workspace/src/github.com/minio/check/printer_test.go
generated
vendored
@ -1,110 +0,0 @@
|
|||||||
package check_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "github.com/minio/check"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ = Suite(&PrinterS{})
|
|
||||||
|
|
||||||
type PrinterS struct{}
|
|
||||||
|
|
||||||
func (s *PrinterS) TestCountSuite(c *C) {
|
|
||||||
suitesRun += 1
|
|
||||||
}
|
|
||||||
|
|
||||||
var printTestFuncLine int
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
printTestFuncLine = getMyLine() + 3
|
|
||||||
}
|
|
||||||
|
|
||||||
func printTestFunc() {
|
|
||||||
println(1) // Comment1
|
|
||||||
if 2 == 2 { // Comment2
|
|
||||||
println(3) // Comment3
|
|
||||||
}
|
|
||||||
switch 5 {
|
|
||||||
case 6:
|
|
||||||
println(6) // Comment6
|
|
||||||
println(7)
|
|
||||||
}
|
|
||||||
switch interface{}(9).(type) { // Comment9
|
|
||||||
case int:
|
|
||||||
println(10)
|
|
||||||
println(11)
|
|
||||||
}
|
|
||||||
select {
|
|
||||||
case <-(chan bool)(nil):
|
|
||||||
println(14)
|
|
||||||
println(15)
|
|
||||||
default:
|
|
||||||
println(16)
|
|
||||||
println(17)
|
|
||||||
}
|
|
||||||
println(19,
|
|
||||||
20)
|
|
||||||
_ = func() {
|
|
||||||
println(21)
|
|
||||||
println(22)
|
|
||||||
}
|
|
||||||
println(24, func() {
|
|
||||||
println(25)
|
|
||||||
})
|
|
||||||
// Leading comment
|
|
||||||
// with multiple lines.
|
|
||||||
println(29) // Comment29
|
|
||||||
}
|
|
||||||
|
|
||||||
var printLineTests = []struct {
|
|
||||||
line int
|
|
||||||
output string
|
|
||||||
}{
|
|
||||||
{1, "println(1) // Comment1"},
|
|
||||||
{2, "if 2 == 2 { // Comment2\n ...\n}"},
|
|
||||||
{3, "println(3) // Comment3"},
|
|
||||||
{5, "switch 5 {\n...\n}"},
|
|
||||||
{6, "case 6:\n println(6) // Comment6\n ..."},
|
|
||||||
{7, "println(7)"},
|
|
||||||
{9, "switch interface{}(9).(type) { // Comment9\n...\n}"},
|
|
||||||
{10, "case int:\n println(10)\n ..."},
|
|
||||||
{14, "case <-(chan bool)(nil):\n println(14)\n ..."},
|
|
||||||
{15, "println(15)"},
|
|
||||||
{16, "default:\n println(16)\n ..."},
|
|
||||||
{17, "println(17)"},
|
|
||||||
{19, "println(19,\n 20)"},
|
|
||||||
{20, "println(19,\n 20)"},
|
|
||||||
{21, "_ = func() {\n println(21)\n println(22)\n}"},
|
|
||||||
{22, "println(22)"},
|
|
||||||
{24, "println(24, func() {\n println(25)\n})"},
|
|
||||||
{25, "println(25)"},
|
|
||||||
{26, "println(24, func() {\n println(25)\n})"},
|
|
||||||
{29, "// Leading comment\n// with multiple lines.\nprintln(29) // Comment29"},
|
|
||||||
}
|
|
||||||
|
|
||||||
// reformat broke test lines above
|
|
||||||
//func (s *PrinterS) TestPrintLine(c *C) {
|
|
||||||
// for _, test := range printLineTests {
|
|
||||||
// output, err := PrintLine("printer_test.go", printTestFuncLine+test.line)
|
|
||||||
// c.Assert(err, IsNil)
|
|
||||||
// c.Assert(output, Equals, test.output)
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
var indentTests = []struct {
|
|
||||||
in, out string
|
|
||||||
}{
|
|
||||||
{"", ""},
|
|
||||||
{"\n", "\n"},
|
|
||||||
{"a", ">>>a"},
|
|
||||||
{"a\n", ">>>a\n"},
|
|
||||||
{"a\nb", ">>>a\n>>>b"},
|
|
||||||
{" ", ">>> "},
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *PrinterS) TestIndent(c *C) {
|
|
||||||
for _, test := range indentTests {
|
|
||||||
out := Indent(test.in, ">>>")
|
|
||||||
c.Assert(out, Equals, test.out)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -3,11 +3,11 @@ Instructions
|
|||||||
|
|
||||||
Install the package with:
|
Install the package with:
|
||||||
|
|
||||||
go get github.com/minio/check
|
go get gopkg.in/check.v1
|
||||||
|
|
||||||
Import it with:
|
Import it with:
|
||||||
|
|
||||||
import "github.com/minio/check"
|
import "gopkg.in/check.v1"
|
||||||
|
|
||||||
and use _check_ as the package name inside the code.
|
and use _check_ as the package name inside the code.
|
||||||
|
|
@ -3,8 +3,8 @@
|
|||||||
package check_test
|
package check_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "github.com/minio/check"
|
|
||||||
"time"
|
"time"
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var benchmarkS = Suite(&BenchmarkS{})
|
var benchmarkS = Suite(&BenchmarkS{})
|
@ -14,7 +14,7 @@ package check_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/minio/check"
|
"gopkg.in/check.v1"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/check"
|
"gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// We count the number of suites run at least to get a vague hint that the
|
// We count the number of suites run at least to get a vague hint that the
|
@ -2,7 +2,7 @@ package check_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/minio/check"
|
"gopkg.in/check.v1"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
@ -3,7 +3,7 @@
|
|||||||
package check_test
|
package check_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
. "github.com/minio/check"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
@ -8,7 +8,7 @@ package check_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/minio/check"
|
"gopkg.in/check.v1"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
@ -4,7 +4,7 @@
|
|||||||
package check_test
|
package check_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/minio/check"
|
"gopkg.in/check.v1"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
104
Godeps/_workspace/src/gopkg.in/check.v1/printer_test.go
generated
vendored
Normal file
104
Godeps/_workspace/src/gopkg.in/check.v1/printer_test.go
generated
vendored
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
package check_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ = Suite(&PrinterS{})
|
||||||
|
|
||||||
|
type PrinterS struct{}
|
||||||
|
|
||||||
|
func (s *PrinterS) TestCountSuite(c *C) {
|
||||||
|
suitesRun += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
var printTestFuncLine int
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
printTestFuncLine = getMyLine() + 3
|
||||||
|
}
|
||||||
|
|
||||||
|
func printTestFunc() {
|
||||||
|
println(1) // Comment1
|
||||||
|
if 2 == 2 { // Comment2
|
||||||
|
println(3) // Comment3
|
||||||
|
}
|
||||||
|
switch 5 {
|
||||||
|
case 6: println(6) // Comment6
|
||||||
|
println(7)
|
||||||
|
}
|
||||||
|
switch interface{}(9).(type) {// Comment9
|
||||||
|
case int: println(10)
|
||||||
|
println(11)
|
||||||
|
}
|
||||||
|
select {
|
||||||
|
case <-(chan bool)(nil): println(14)
|
||||||
|
println(15)
|
||||||
|
default: println(16)
|
||||||
|
println(17)
|
||||||
|
}
|
||||||
|
println(19,
|
||||||
|
20)
|
||||||
|
_ = func() { println(21)
|
||||||
|
println(22)
|
||||||
|
}
|
||||||
|
println(24, func() {
|
||||||
|
println(25)
|
||||||
|
})
|
||||||
|
// Leading comment
|
||||||
|
// with multiple lines.
|
||||||
|
println(29) // Comment29
|
||||||
|
}
|
||||||
|
|
||||||
|
var printLineTests = []struct {
|
||||||
|
line int
|
||||||
|
output string
|
||||||
|
}{
|
||||||
|
{1, "println(1) // Comment1"},
|
||||||
|
{2, "if 2 == 2 { // Comment2\n ...\n}"},
|
||||||
|
{3, "println(3) // Comment3"},
|
||||||
|
{5, "switch 5 {\n...\n}"},
|
||||||
|
{6, "case 6:\n println(6) // Comment6\n ..."},
|
||||||
|
{7, "println(7)"},
|
||||||
|
{9, "switch interface{}(9).(type) { // Comment9\n...\n}"},
|
||||||
|
{10, "case int:\n println(10)\n ..."},
|
||||||
|
{14, "case <-(chan bool)(nil):\n println(14)\n ..."},
|
||||||
|
{15, "println(15)"},
|
||||||
|
{16, "default:\n println(16)\n ..."},
|
||||||
|
{17, "println(17)"},
|
||||||
|
{19, "println(19,\n 20)"},
|
||||||
|
{20, "println(19,\n 20)"},
|
||||||
|
{21, "_ = func() {\n println(21)\n println(22)\n}"},
|
||||||
|
{22, "println(22)"},
|
||||||
|
{24, "println(24, func() {\n println(25)\n})"},
|
||||||
|
{25, "println(25)"},
|
||||||
|
{26, "println(24, func() {\n println(25)\n})"},
|
||||||
|
{29, "// Leading comment\n// with multiple lines.\nprintln(29) // Comment29"},
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PrinterS) TestPrintLine(c *C) {
|
||||||
|
for _, test := range printLineTests {
|
||||||
|
output, err := PrintLine("printer_test.go", printTestFuncLine+test.line)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(output, Equals, test.output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var indentTests = []struct {
|
||||||
|
in, out string
|
||||||
|
}{
|
||||||
|
{"", ""},
|
||||||
|
{"\n", "\n"},
|
||||||
|
{"a", ">>>a"},
|
||||||
|
{"a\n", ">>>a\n"},
|
||||||
|
{"a\nb", ">>>a\n>>>b"},
|
||||||
|
{" ", ">>> "},
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PrinterS) TestIndent(c *C) {
|
||||||
|
for _, test := range indentTests {
|
||||||
|
out := Indent(test.in, ">>>")
|
||||||
|
c.Assert(out, Equals, test.out)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,7 +4,7 @@ package check_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
. "github.com/minio/check"
|
. "gopkg.in/check.v1"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@ -400,7 +400,7 @@ func (s *RunS) TestStreamModeWithMiss(c *C) {
|
|||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
// Verify that that the keep work dir request indeed does so.
|
// Verify that that the keep work dir request indeed does so.
|
||||||
|
|
||||||
type WorkDirSuite struct{}
|
type WorkDirSuite struct {}
|
||||||
|
|
||||||
func (s *WorkDirSuite) Test(c *C) {
|
func (s *WorkDirSuite) Test(c *C) {
|
||||||
c.MkDir()
|
c.MkDir()
|
||||||
@ -411,7 +411,7 @@ func (s *RunS) TestKeepWorkDir(c *C) {
|
|||||||
runConf := RunConf{Output: &output, Verbose: true, KeepWorkDir: true}
|
runConf := RunConf{Output: &output, Verbose: true, KeepWorkDir: true}
|
||||||
result := Run(&WorkDirSuite{}, &runConf)
|
result := Run(&WorkDirSuite{}, &runConf)
|
||||||
|
|
||||||
c.Assert(result.String(), Matches, ".*\nWORK="+result.WorkDir)
|
c.Assert(result.String(), Matches, ".*\nWORK=" + result.WorkDir)
|
||||||
|
|
||||||
stat, err := os.Stat(result.WorkDir)
|
stat, err := os.Stat(result.WorkDir)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
@ -19,8 +19,8 @@ package auth_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
|
||||||
"github.com/minio/minio/pkg/auth"
|
"github.com/minio/minio/pkg/auth"
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) { TestingT(t) }
|
func Test(t *testing.T) { TestingT(t) }
|
||||||
|
@ -23,8 +23,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
|
||||||
"github.com/minio/minio/pkg/cpu"
|
"github.com/minio/minio/pkg/cpu"
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) { TestingT(t) }
|
func Test(t *testing.T) { TestingT(t) }
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
|
||||||
"github.com/minio/minio/pkg/crypto/md5"
|
"github.com/minio/minio/pkg/crypto/md5"
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) { TestingT(t) }
|
func Test(t *testing.T) { TestingT(t) }
|
||||||
|
@ -19,7 +19,6 @@ package donut
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash"
|
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
@ -154,6 +153,13 @@ func (b bucket) ListObjects(prefix, marker, delimiter string, maxkeys int) (List
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ListObjectsResults{}, iodine.New(err, nil)
|
return ListObjectsResults{}, iodine.New(err, nil)
|
||||||
}
|
}
|
||||||
|
for objectName := range bucketMetadata.Buckets[b.getBucketName()].Multiparts {
|
||||||
|
if strings.HasPrefix(objectName, strings.TrimSpace(prefix)) {
|
||||||
|
if objectName > marker {
|
||||||
|
objects = append(objects, objectName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
for objectName := range bucketMetadata.Buckets[b.getBucketName()].BucketObjects {
|
for objectName := range bucketMetadata.Buckets[b.getBucketName()].BucketObjects {
|
||||||
if strings.HasPrefix(objectName, strings.TrimSpace(prefix)) {
|
if strings.HasPrefix(objectName, strings.TrimSpace(prefix)) {
|
||||||
if objectName > marker {
|
if objectName > marker {
|
||||||
@ -171,7 +177,7 @@ func (b bucket) ListObjects(prefix, marker, delimiter string, maxkeys int) (List
|
|||||||
filteredObjects = HasNoDelimiter(objects, delimiter)
|
filteredObjects = HasNoDelimiter(objects, delimiter)
|
||||||
prefixes = HasDelimiter(objects, delimiter)
|
prefixes = HasDelimiter(objects, delimiter)
|
||||||
prefixes = SplitDelimiter(prefixes, delimiter)
|
prefixes = SplitDelimiter(prefixes, delimiter)
|
||||||
prefixes = SortU(prefixes)
|
prefixes = SortUnique(prefixes)
|
||||||
}
|
}
|
||||||
var results []string
|
var results []string
|
||||||
var commonPrefixes []string
|
var commonPrefixes []string
|
||||||
@ -264,8 +270,9 @@ func (b bucket) WriteObject(objectName string, objectData io.Reader, expectedMD5
|
|||||||
CleanupWritersOnError(writers)
|
CleanupWritersOnError(writers)
|
||||||
return ObjectMetadata{}, iodine.New(err, nil)
|
return ObjectMetadata{}, iodine.New(err, nil)
|
||||||
}
|
}
|
||||||
|
mwriter := io.MultiWriter(sumMD5, sum256, sum512)
|
||||||
// write encoded data with k, m and writers
|
// write encoded data with k, m and writers
|
||||||
chunkCount, totalLength, err := b.writeObjectData(k, m, writers, objectData, sumMD5, sum256, sum512)
|
chunkCount, totalLength, err := b.writeObjectData(k, m, writers, objectData, mwriter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
CleanupWritersOnError(writers)
|
CleanupWritersOnError(writers)
|
||||||
return ObjectMetadata{}, iodine.New(err, nil)
|
return ObjectMetadata{}, iodine.New(err, nil)
|
||||||
@ -364,11 +371,11 @@ func (b bucket) writeObjectMetadata(objectName string, objMetadata ObjectMetadat
|
|||||||
|
|
||||||
// readObjectMetadata - read object metadata
|
// readObjectMetadata - read object metadata
|
||||||
func (b bucket) readObjectMetadata(objectName string) (ObjectMetadata, error) {
|
func (b bucket) readObjectMetadata(objectName string) (ObjectMetadata, error) {
|
||||||
objMetadata := ObjectMetadata{}
|
|
||||||
if objectName == "" {
|
if objectName == "" {
|
||||||
return ObjectMetadata{}, iodine.New(InvalidArgument{}, nil)
|
return ObjectMetadata{}, iodine.New(InvalidArgument{}, nil)
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
|
objMetadata := ObjectMetadata{}
|
||||||
objMetadataReaders, err := b.getObjectReaders(objectName, objectMetadataConfig)
|
objMetadataReaders, err := b.getObjectReaders(objectName, objectMetadataConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ObjectMetadata{}, iodine.New(err, nil)
|
return ObjectMetadata{}, iodine.New(err, nil)
|
||||||
@ -415,7 +422,7 @@ func (b bucket) getDataAndParity(totalWriters int) (k uint8, m uint8, err error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// writeObjectData -
|
// writeObjectData -
|
||||||
func (b bucket) writeObjectData(k, m uint8, writers []io.WriteCloser, objectData io.Reader, sumMD5, sum256, sum512 hash.Hash) (int, int, error) {
|
func (b bucket) writeObjectData(k, m uint8, writers []io.WriteCloser, objectData io.Reader, writer io.Writer) (int, int, error) {
|
||||||
encoder, err := newEncoder(k, m, "Cauchy")
|
encoder, err := newEncoder(k, m, "Cauchy")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, iodine.New(err, nil)
|
return 0, 0, iodine.New(err, nil)
|
||||||
@ -432,9 +439,7 @@ func (b bucket) writeObjectData(k, m uint8, writers []io.WriteCloser, objectData
|
|||||||
return 0, 0, iodine.New(err, nil)
|
return 0, 0, iodine.New(err, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
sumMD5.Write(chunk.Data)
|
writer.Write(chunk.Data)
|
||||||
sum256.Write(chunk.Data)
|
|
||||||
sum512.Write(chunk.Data)
|
|
||||||
for blockIndex, block := range encodedBlocks {
|
for blockIndex, block := range encodedBlocks {
|
||||||
errCh := make(chan error, 1)
|
errCh := make(chan error, 1)
|
||||||
go func(writer io.Writer, reader io.Reader) {
|
go func(writer io.Writer, reader io.Reader) {
|
||||||
|
2
pkg/donut/cache/data/data_test.go
vendored
2
pkg/donut/cache/data/data_test.go
vendored
@ -19,7 +19,7 @@ package data
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) { TestingT(t) }
|
func Test(t *testing.T) { TestingT(t) }
|
||||||
|
2
pkg/donut/cache/metadata/metadata_test.go
vendored
2
pkg/donut/cache/metadata/metadata_test.go
vendored
@ -19,7 +19,7 @@ package metadata
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) { TestingT(t) }
|
func Test(t *testing.T) { TestingT(t) }
|
||||||
|
@ -168,8 +168,8 @@ func SplitDelimiter(objects []string, delim string) []string {
|
|||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
// SortU sort a slice in lexical order, removing duplicate elements
|
// SortUnique sort a slice in lexical order, removing duplicate elements
|
||||||
func SortU(objects []string) []string {
|
func SortUnique(objects []string) []string {
|
||||||
objectMap := make(map[string]string)
|
objectMap := make(map[string]string)
|
||||||
for _, v := range objects {
|
for _, v := range objects {
|
||||||
objectMap[v] = v
|
objectMap[v] = v
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDisk(t *testing.T) { TestingT(t) }
|
func TestDisk(t *testing.T) { TestingT(t) }
|
||||||
|
@ -191,7 +191,7 @@ func (donut API) putObjectPart(bucket, object, expectedMD5Sum, uploadID string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return PartMetadata{}, iodine.New(err, errParams)
|
return PartMetadata{}, iodine.New(err, errParams)
|
||||||
}
|
}
|
||||||
if _, ok := bucketMeta.Buckets[bucket].Multiparts[object+uploadID]; !ok {
|
if _, ok := bucketMeta.Buckets[bucket].Multiparts[object]; !ok {
|
||||||
return PartMetadata{}, iodine.New(InvalidUploadID{UploadID: uploadID}, nil)
|
return PartMetadata{}, iodine.New(InvalidUploadID{UploadID: uploadID}, nil)
|
||||||
}
|
}
|
||||||
if _, ok := bucketMeta.Buckets[bucket].BucketObjects[object]; ok {
|
if _, ok := bucketMeta.Buckets[bucket].BucketObjects[object]; ok {
|
||||||
@ -208,9 +208,9 @@ func (donut API) putObjectPart(bucket, object, expectedMD5Sum, uploadID string,
|
|||||||
ETag: objmetadata.MD5Sum,
|
ETag: objmetadata.MD5Sum,
|
||||||
Size: objmetadata.Size,
|
Size: objmetadata.Size,
|
||||||
}
|
}
|
||||||
multipartSession := bucketMeta.Buckets[bucket].Multiparts[object+uploadID]
|
multipartSession := bucketMeta.Buckets[bucket].Multiparts[object]
|
||||||
multipartSession.Parts[strconv.Itoa(partID)] = partMetadata
|
multipartSession.Parts[strconv.Itoa(partID)] = partMetadata
|
||||||
bucketMeta.Buckets[bucket].Multiparts[object+uploadID] = multipartSession
|
bucketMeta.Buckets[bucket].Multiparts[object] = multipartSession
|
||||||
if err := donut.setDonutBucketMetadata(bucketMeta); err != nil {
|
if err := donut.setDonutBucketMetadata(bucketMeta); err != nil {
|
||||||
return PartMetadata{}, iodine.New(err, errParams)
|
return PartMetadata{}, iodine.New(err, errParams)
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ func (donut API) newMultipartUpload(bucket, object, contentType string) (string,
|
|||||||
Parts: make(map[string]PartMetadata),
|
Parts: make(map[string]PartMetadata),
|
||||||
TotalParts: 0,
|
TotalParts: 0,
|
||||||
}
|
}
|
||||||
multiparts[object+uploadID] = multipartSession
|
multiparts[object] = multipartSession
|
||||||
bucketMetadata.Multiparts = multiparts
|
bucketMetadata.Multiparts = multiparts
|
||||||
allbuckets.Buckets[bucket] = bucketMetadata
|
allbuckets.Buckets[bucket] = bucketMetadata
|
||||||
|
|
||||||
@ -326,12 +326,16 @@ func (donut API) listObjectParts(bucket, object string, resources ObjectResource
|
|||||||
if _, ok := donut.buckets[bucket]; !ok {
|
if _, ok := donut.buckets[bucket]; !ok {
|
||||||
return ObjectResourcesMetadata{}, iodine.New(BucketNotFound{Bucket: bucket}, errParams)
|
return ObjectResourcesMetadata{}, iodine.New(BucketNotFound{Bucket: bucket}, errParams)
|
||||||
}
|
}
|
||||||
bucketMetadata, err := donut.getDonutBucketMetadata()
|
allBuckets, err := donut.getDonutBucketMetadata()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ObjectResourcesMetadata{}, iodine.New(err, errParams)
|
return ObjectResourcesMetadata{}, iodine.New(err, errParams)
|
||||||
}
|
}
|
||||||
if _, ok := bucketMetadata.Buckets[bucket].Multiparts[object+resources.UploadID]; !ok {
|
bucketMetadata := allBuckets.Buckets[bucket]
|
||||||
return ObjectResourcesMetadata{}, iodine.New(InvalidUploadID{UploadID: resources.UploadID}, nil)
|
if _, ok := bucketMetadata.Multiparts[object]; !ok {
|
||||||
|
return ObjectResourcesMetadata{}, iodine.New(InvalidUploadID{UploadID: resources.UploadID}, errParams)
|
||||||
|
}
|
||||||
|
if bucketMetadata.Multiparts[object].UploadID != resources.UploadID {
|
||||||
|
return ObjectResourcesMetadata{}, iodine.New(InvalidUploadID{UploadID: resources.UploadID}, errParams)
|
||||||
}
|
}
|
||||||
objectResourcesMetadata := resources
|
objectResourcesMetadata := resources
|
||||||
objectResourcesMetadata.Bucket = bucket
|
objectResourcesMetadata.Bucket = bucket
|
||||||
@ -344,7 +348,7 @@ func (donut API) listObjectParts(bucket, object string, resources ObjectResource
|
|||||||
default:
|
default:
|
||||||
startPartNumber = objectResourcesMetadata.PartNumberMarker
|
startPartNumber = objectResourcesMetadata.PartNumberMarker
|
||||||
}
|
}
|
||||||
for i := startPartNumber; i <= bucketMetadata.Buckets[bucket].Multiparts[object+resources.UploadID].TotalParts; i++ {
|
for i := startPartNumber; i <= bucketMetadata.Multiparts[object].TotalParts; i++ {
|
||||||
if len(parts) > objectResourcesMetadata.MaxParts {
|
if len(parts) > objectResourcesMetadata.MaxParts {
|
||||||
sort.Sort(partNumber(parts))
|
sort.Sort(partNumber(parts))
|
||||||
objectResourcesMetadata.IsTruncated = true
|
objectResourcesMetadata.IsTruncated = true
|
||||||
@ -352,7 +356,7 @@ func (donut API) listObjectParts(bucket, object string, resources ObjectResource
|
|||||||
objectResourcesMetadata.NextPartNumberMarker = i
|
objectResourcesMetadata.NextPartNumberMarker = i
|
||||||
return objectResourcesMetadata, nil
|
return objectResourcesMetadata, nil
|
||||||
}
|
}
|
||||||
part, ok := bucketMetadata.Buckets[bucket].Multiparts[object+resources.UploadID].Parts[strconv.Itoa(i)]
|
part, ok := bucketMetadata.Multiparts[object].Parts[strconv.Itoa(i)]
|
||||||
if !ok {
|
if !ok {
|
||||||
return ObjectResourcesMetadata{}, iodine.New(InvalidPart{}, nil)
|
return ObjectResourcesMetadata{}, iodine.New(InvalidPart{}, nil)
|
||||||
}
|
}
|
||||||
@ -382,11 +386,15 @@ func (donut API) completeMultipartUpload(bucket, object, uploadID string, data i
|
|||||||
if _, ok := donut.buckets[bucket]; !ok {
|
if _, ok := donut.buckets[bucket]; !ok {
|
||||||
return ObjectMetadata{}, iodine.New(BucketNotFound{Bucket: bucket}, errParams)
|
return ObjectMetadata{}, iodine.New(BucketNotFound{Bucket: bucket}, errParams)
|
||||||
}
|
}
|
||||||
bucketMetadata, err := donut.getDonutBucketMetadata()
|
allBuckets, err := donut.getDonutBucketMetadata()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ObjectMetadata{}, iodine.New(err, errParams)
|
return ObjectMetadata{}, iodine.New(err, errParams)
|
||||||
}
|
}
|
||||||
if _, ok := bucketMetadata.Buckets[bucket].Multiparts[object+uploadID]; !ok {
|
bucketMetadata := allBuckets.Buckets[bucket]
|
||||||
|
if _, ok := bucketMetadata.Multiparts[object]; !ok {
|
||||||
|
return ObjectMetadata{}, iodine.New(InvalidUploadID{UploadID: uploadID}, errParams)
|
||||||
|
}
|
||||||
|
if bucketMetadata.Multiparts[object].UploadID != uploadID {
|
||||||
return ObjectMetadata{}, iodine.New(InvalidUploadID{UploadID: uploadID}, errParams)
|
return ObjectMetadata{}, iodine.New(InvalidUploadID{UploadID: uploadID}, errParams)
|
||||||
}
|
}
|
||||||
partBytes, err := ioutil.ReadAll(data)
|
partBytes, err := ioutil.ReadAll(data)
|
||||||
@ -409,10 +417,15 @@ func (donut API) completeMultipartUpload(bucket, object, uploadID string, data i
|
|||||||
if !sort.IsSorted(completedParts(parts.Part)) {
|
if !sort.IsSorted(completedParts(parts.Part)) {
|
||||||
return ObjectMetadata{}, iodine.New(InvalidPartOrder{}, errParams)
|
return ObjectMetadata{}, iodine.New(InvalidPartOrder{}, errParams)
|
||||||
}
|
}
|
||||||
|
for _, part := range parts.Part {
|
||||||
|
if part.ETag != bucketMetadata.Multiparts[object].Parts[strconv.Itoa(part.PartNumber)].ETag {
|
||||||
|
return ObjectMetadata{}, iodine.New(InvalidPart{}, errParams)
|
||||||
|
}
|
||||||
|
}
|
||||||
var finalETagBytes []byte
|
var finalETagBytes []byte
|
||||||
var finalSize int64
|
var finalSize int64
|
||||||
totalParts := strconv.Itoa(bucketMetadata.Buckets[bucket].Multiparts[object+uploadID].TotalParts)
|
totalParts := strconv.Itoa(bucketMetadata.Multiparts[object].TotalParts)
|
||||||
for _, part := range bucketMetadata.Buckets[bucket].Multiparts[object+uploadID].Parts {
|
for _, part := range bucketMetadata.Multiparts[object].Parts {
|
||||||
partETagBytes, err := hex.DecodeString(part.ETag)
|
partETagBytes, err := hex.DecodeString(part.ETag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ObjectMetadata{}, iodine.New(err, errParams)
|
return ObjectMetadata{}, iodine.New(err, errParams)
|
||||||
@ -426,7 +439,7 @@ func (donut API) completeMultipartUpload(bucket, object, uploadID string, data i
|
|||||||
objMetadata.Object = object
|
objMetadata.Object = object
|
||||||
objMetadata.Bucket = bucket
|
objMetadata.Bucket = bucket
|
||||||
objMetadata.Size = finalSize
|
objMetadata.Size = finalSize
|
||||||
objMetadata.Created = bucketMetadata.Buckets[bucket].Multiparts[object+uploadID].Parts[totalParts].LastModified
|
objMetadata.Created = bucketMetadata.Multiparts[object].Parts[totalParts].LastModified
|
||||||
return objMetadata, nil
|
return objMetadata, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,7 +459,6 @@ func (donut API) listMultipartUploads(bucket string, resources BucketMultipartRe
|
|||||||
return BucketMultipartResourcesMetadata{}, iodine.New(err, errParams)
|
return BucketMultipartResourcesMetadata{}, iodine.New(err, errParams)
|
||||||
}
|
}
|
||||||
bucketMetadata := allbuckets.Buckets[bucket]
|
bucketMetadata := allbuckets.Buckets[bucket]
|
||||||
|
|
||||||
var uploads []*UploadMetadata
|
var uploads []*UploadMetadata
|
||||||
for key, session := range bucketMetadata.Multiparts {
|
for key, session := range bucketMetadata.Multiparts {
|
||||||
if strings.HasPrefix(key, resources.Prefix) {
|
if strings.HasPrefix(key, resources.Prefix) {
|
||||||
@ -510,7 +522,13 @@ func (donut API) abortMultipartUpload(bucket, object, uploadID string) error {
|
|||||||
return iodine.New(err, errParams)
|
return iodine.New(err, errParams)
|
||||||
}
|
}
|
||||||
bucketMetadata := allbuckets.Buckets[bucket]
|
bucketMetadata := allbuckets.Buckets[bucket]
|
||||||
delete(bucketMetadata.Multiparts, object+uploadID)
|
if _, ok := bucketMetadata.Multiparts[object]; !ok {
|
||||||
|
return iodine.New(InvalidUploadID{UploadID: uploadID}, errParams)
|
||||||
|
}
|
||||||
|
if bucketMetadata.Multiparts[object].UploadID != uploadID {
|
||||||
|
return iodine.New(InvalidUploadID{UploadID: uploadID}, errParams)
|
||||||
|
}
|
||||||
|
delete(bucketMetadata.Multiparts, object)
|
||||||
|
|
||||||
allbuckets.Buckets[bucket] = bucketMetadata
|
allbuckets.Buckets[bucket] = bucketMetadata
|
||||||
if err := donut.setDonutBucketMetadata(allbuckets); err != nil {
|
if err := donut.setDonutBucketMetadata(allbuckets); err != nil {
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDonut(t *testing.T) { TestingT(t) }
|
func TestDonut(t *testing.T) { TestingT(t) }
|
||||||
|
@ -579,7 +579,7 @@ func (donut API) ListObjects(bucket string, resources BucketResourcesMetadata, s
|
|||||||
filteredKeys = HasNoDelimiter(keys, resources.Delimiter)
|
filteredKeys = HasNoDelimiter(keys, resources.Delimiter)
|
||||||
prefixes = HasDelimiter(keys, resources.Delimiter)
|
prefixes = HasDelimiter(keys, resources.Delimiter)
|
||||||
prefixes = SplitDelimiter(prefixes, resources.Delimiter)
|
prefixes = SplitDelimiter(prefixes, resources.Delimiter)
|
||||||
prefixes = SortU(prefixes)
|
prefixes = SortUnique(prefixes)
|
||||||
}
|
}
|
||||||
for _, commonPrefix := range prefixes {
|
for _, commonPrefix := range prefixes {
|
||||||
resources.CommonPrefixes = append(resources.CommonPrefixes, resources.Prefix+commonPrefix)
|
resources.CommonPrefixes = append(resources.CommonPrefixes, resources.Prefix+commonPrefix)
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCache(t *testing.T) { TestingT(t) }
|
func TestCache(t *testing.T) { TestingT(t) }
|
||||||
|
@ -24,8 +24,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
|
||||||
"github.com/minio/minio/pkg/donut/split"
|
"github.com/minio/minio/pkg/donut/split"
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MySuite struct{}
|
type MySuite struct{}
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MySuite struct{}
|
type MySuite struct{}
|
||||||
|
@ -19,7 +19,7 @@ package erasure
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func corruptChunks(chunks [][]byte, errorIndex []int) [][]byte {
|
func corruptChunks(chunks [][]byte, errorIndex []int) [][]byte {
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) { TestingT(t) }
|
func Test(t *testing.T) { TestingT(t) }
|
||||||
|
@ -28,9 +28,9 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
|
||||||
"github.com/minio/minio/pkg/donut"
|
"github.com/minio/minio/pkg/donut"
|
||||||
"github.com/minio/minio/pkg/server/api"
|
"github.com/minio/minio/pkg/server/api"
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAPIDonutCache(t *testing.T) { TestingT(t) }
|
func TestAPIDonutCache(t *testing.T) { TestingT(t) }
|
||||||
|
@ -29,9 +29,9 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
|
||||||
"github.com/minio/minio/pkg/donut"
|
"github.com/minio/minio/pkg/donut"
|
||||||
"github.com/minio/minio/pkg/server/api"
|
"github.com/minio/minio/pkg/server/api"
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAPIDonut(t *testing.T) { TestingT(t) }
|
func TestAPIDonut(t *testing.T) { TestingT(t) }
|
||||||
|
@ -29,10 +29,10 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
|
||||||
"github.com/minio/minio/pkg/auth"
|
"github.com/minio/minio/pkg/auth"
|
||||||
"github.com/minio/minio/pkg/donut"
|
"github.com/minio/minio/pkg/donut"
|
||||||
"github.com/minio/minio/pkg/server/api"
|
"github.com/minio/minio/pkg/server/api"
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAPISignatureV4(t *testing.T) { TestingT(t) }
|
func TestAPISignatureV4(t *testing.T) { TestingT(t) }
|
||||||
|
@ -21,8 +21,8 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
|
||||||
"github.com/minio/minio/pkg/iodine"
|
"github.com/minio/minio/pkg/iodine"
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) { TestingT(t) }
|
func Test(t *testing.T) { TestingT(t) }
|
||||||
|
@ -22,9 +22,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
jsonrpc "github.com/gorilla/rpc/v2/json"
|
jsonrpc "github.com/gorilla/rpc/v2/json"
|
||||||
. "github.com/minio/check"
|
|
||||||
"github.com/minio/minio/pkg/controller"
|
"github.com/minio/minio/pkg/controller"
|
||||||
"github.com/minio/minio/pkg/server/rpc"
|
"github.com/minio/minio/pkg/server/rpc"
|
||||||
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRPC(t *testing.T) { TestingT(t) }
|
func TestRPC(t *testing.T) { TestingT(t) }
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
. "github.com/minio/check"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test(t *testing.T) { TestingT(t) }
|
func Test(t *testing.T) { TestingT(t) }
|
||||||
|
Loading…
Reference in New Issue
Block a user