diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index bf818444b..f705c6d24 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -1,6 +1,6 @@ { "ImportPath": "github.com/minio/minio", - "GoVersion": "go1.4", + "GoVersion": "go1.4.2", "Packages": [ "./..." ], @@ -37,14 +37,14 @@ "ImportPath": "github.com/gorilla/rpc/v2", "Rev": "f6dbf92d77c723632269bf29154cc91f2507693b" }, - { - "ImportPath": "github.com/minio/check", - "Rev": "67f8c16c6c27bb03c82e41c2be533ace00035ab4" - }, { "ImportPath": "github.com/minio/cli", "Comment": "1.2.0-112-g823349c", "Rev": "823349ce91e76834a4af0119d5bbc58fd4d2c6b0" + }, + { + "ImportPath": "gopkg.in/check.v1", + "Rev": "64131543e7896d5bcc6bd5a76287eb75ea96c673" } ] } diff --git a/Godeps/_workspace/src/github.com/minio/check/printer_test.go b/Godeps/_workspace/src/github.com/minio/check/printer_test.go deleted file mode 100644 index 885ea3342..000000000 --- a/Godeps/_workspace/src/github.com/minio/check/printer_test.go +++ /dev/null @@ -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) - } - -} diff --git a/Godeps/_workspace/src/github.com/minio/check/.gitignore b/Godeps/_workspace/src/gopkg.in/check.v1/.gitignore similarity index 100% rename from Godeps/_workspace/src/github.com/minio/check/.gitignore rename to Godeps/_workspace/src/gopkg.in/check.v1/.gitignore diff --git a/Godeps/_workspace/src/github.com/minio/check/LICENSE b/Godeps/_workspace/src/gopkg.in/check.v1/LICENSE similarity index 100% rename from Godeps/_workspace/src/github.com/minio/check/LICENSE rename to Godeps/_workspace/src/gopkg.in/check.v1/LICENSE diff --git a/Godeps/_workspace/src/github.com/minio/check/README.md b/Godeps/_workspace/src/gopkg.in/check.v1/README.md similarity index 78% rename from Godeps/_workspace/src/github.com/minio/check/README.md rename to Godeps/_workspace/src/gopkg.in/check.v1/README.md index 3cf695e5c..0ca9e5726 100644 --- a/Godeps/_workspace/src/github.com/minio/check/README.md +++ b/Godeps/_workspace/src/gopkg.in/check.v1/README.md @@ -3,11 +3,11 @@ Instructions Install the package with: - go get github.com/minio/check + go get gopkg.in/check.v1 Import it with: - import "github.com/minio/check" + import "gopkg.in/check.v1" and use _check_ as the package name inside the code. diff --git a/Godeps/_workspace/src/github.com/minio/check/TODO b/Godeps/_workspace/src/gopkg.in/check.v1/TODO similarity index 100% rename from Godeps/_workspace/src/github.com/minio/check/TODO rename to Godeps/_workspace/src/gopkg.in/check.v1/TODO diff --git a/Godeps/_workspace/src/github.com/minio/check/benchmark.go b/Godeps/_workspace/src/gopkg.in/check.v1/benchmark.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/check/benchmark.go rename to Godeps/_workspace/src/gopkg.in/check.v1/benchmark.go diff --git a/Godeps/_workspace/src/github.com/minio/check/benchmark_test.go b/Godeps/_workspace/src/gopkg.in/check.v1/benchmark_test.go similarity index 98% rename from Godeps/_workspace/src/github.com/minio/check/benchmark_test.go rename to Godeps/_workspace/src/gopkg.in/check.v1/benchmark_test.go index b35dbb6f6..4dd827c16 100644 --- a/Godeps/_workspace/src/github.com/minio/check/benchmark_test.go +++ b/Godeps/_workspace/src/gopkg.in/check.v1/benchmark_test.go @@ -3,8 +3,8 @@ package check_test import ( - . "github.com/minio/check" "time" + . "gopkg.in/check.v1" ) var benchmarkS = Suite(&BenchmarkS{}) diff --git a/Godeps/_workspace/src/github.com/minio/check/bootstrap_test.go b/Godeps/_workspace/src/gopkg.in/check.v1/bootstrap_test.go similarity index 98% rename from Godeps/_workspace/src/github.com/minio/check/bootstrap_test.go rename to Godeps/_workspace/src/gopkg.in/check.v1/bootstrap_test.go index d1d1b4513..e55f327c7 100644 --- a/Godeps/_workspace/src/github.com/minio/check/bootstrap_test.go +++ b/Godeps/_workspace/src/gopkg.in/check.v1/bootstrap_test.go @@ -14,7 +14,7 @@ package check_test import ( "fmt" - "github.com/minio/check" + "gopkg.in/check.v1" "strings" ) diff --git a/Godeps/_workspace/src/github.com/minio/check/check.go b/Godeps/_workspace/src/gopkg.in/check.v1/check.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/check/check.go rename to Godeps/_workspace/src/gopkg.in/check.v1/check.go diff --git a/Godeps/_workspace/src/github.com/minio/check/check_test.go b/Godeps/_workspace/src/gopkg.in/check.v1/check_test.go similarity index 99% rename from Godeps/_workspace/src/github.com/minio/check/check_test.go rename to Godeps/_workspace/src/gopkg.in/check.v1/check_test.go index 4c087b749..871b32527 100644 --- a/Godeps/_workspace/src/github.com/minio/check/check_test.go +++ b/Godeps/_workspace/src/gopkg.in/check.v1/check_test.go @@ -12,7 +12,7 @@ import ( "testing" "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 diff --git a/Godeps/_workspace/src/github.com/minio/check/checkers.go b/Godeps/_workspace/src/gopkg.in/check.v1/checkers.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/check/checkers.go rename to Godeps/_workspace/src/gopkg.in/check.v1/checkers.go diff --git a/Godeps/_workspace/src/github.com/minio/check/checkers_test.go b/Godeps/_workspace/src/gopkg.in/check.v1/checkers_test.go similarity index 99% rename from Godeps/_workspace/src/github.com/minio/check/checkers_test.go rename to Godeps/_workspace/src/gopkg.in/check.v1/checkers_test.go index 9bdf5c621..5c6974746 100644 --- a/Godeps/_workspace/src/github.com/minio/check/checkers_test.go +++ b/Godeps/_workspace/src/gopkg.in/check.v1/checkers_test.go @@ -2,7 +2,7 @@ package check_test import ( "errors" - "github.com/minio/check" + "gopkg.in/check.v1" "reflect" "runtime" ) diff --git a/Godeps/_workspace/src/github.com/minio/check/export_test.go b/Godeps/_workspace/src/gopkg.in/check.v1/export_test.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/check/export_test.go rename to Godeps/_workspace/src/gopkg.in/check.v1/export_test.go diff --git a/Godeps/_workspace/src/github.com/minio/check/fixture_test.go b/Godeps/_workspace/src/gopkg.in/check.v1/fixture_test.go similarity index 99% rename from Godeps/_workspace/src/github.com/minio/check/fixture_test.go rename to Godeps/_workspace/src/gopkg.in/check.v1/fixture_test.go index 2ecad126c..2bff9e163 100644 --- a/Godeps/_workspace/src/github.com/minio/check/fixture_test.go +++ b/Godeps/_workspace/src/gopkg.in/check.v1/fixture_test.go @@ -3,7 +3,7 @@ package check_test import ( - . "github.com/minio/check" + . "gopkg.in/check.v1" ) // ----------------------------------------------------------------------- diff --git a/Godeps/_workspace/src/github.com/minio/check/foundation_test.go b/Godeps/_workspace/src/gopkg.in/check.v1/foundation_test.go similarity index 99% rename from Godeps/_workspace/src/github.com/minio/check/foundation_test.go rename to Godeps/_workspace/src/gopkg.in/check.v1/foundation_test.go index 0336195f9..8ecf7915f 100644 --- a/Godeps/_workspace/src/github.com/minio/check/foundation_test.go +++ b/Godeps/_workspace/src/gopkg.in/check.v1/foundation_test.go @@ -8,7 +8,7 @@ package check_test import ( "fmt" - "github.com/minio/check" + "gopkg.in/check.v1" "log" "os" "regexp" diff --git a/Godeps/_workspace/src/github.com/minio/check/helpers.go b/Godeps/_workspace/src/gopkg.in/check.v1/helpers.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/check/helpers.go rename to Godeps/_workspace/src/gopkg.in/check.v1/helpers.go diff --git a/Godeps/_workspace/src/github.com/minio/check/helpers_test.go b/Godeps/_workspace/src/gopkg.in/check.v1/helpers_test.go similarity index 99% rename from Godeps/_workspace/src/github.com/minio/check/helpers_test.go rename to Godeps/_workspace/src/gopkg.in/check.v1/helpers_test.go index 9bb0986a6..4baa656ba 100644 --- a/Godeps/_workspace/src/github.com/minio/check/helpers_test.go +++ b/Godeps/_workspace/src/gopkg.in/check.v1/helpers_test.go @@ -4,7 +4,7 @@ package check_test import ( - "github.com/minio/check" + "gopkg.in/check.v1" "os" "reflect" "runtime" diff --git a/Godeps/_workspace/src/github.com/minio/check/printer.go b/Godeps/_workspace/src/gopkg.in/check.v1/printer.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/check/printer.go rename to Godeps/_workspace/src/gopkg.in/check.v1/printer.go diff --git a/Godeps/_workspace/src/gopkg.in/check.v1/printer_test.go b/Godeps/_workspace/src/gopkg.in/check.v1/printer_test.go new file mode 100644 index 000000000..538b2d52e --- /dev/null +++ b/Godeps/_workspace/src/gopkg.in/check.v1/printer_test.go @@ -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) + } + +} diff --git a/Godeps/_workspace/src/github.com/minio/check/run.go b/Godeps/_workspace/src/gopkg.in/check.v1/run.go similarity index 100% rename from Godeps/_workspace/src/github.com/minio/check/run.go rename to Godeps/_workspace/src/gopkg.in/check.v1/run.go diff --git a/Godeps/_workspace/src/github.com/minio/check/run_test.go b/Godeps/_workspace/src/gopkg.in/check.v1/run_test.go similarity index 99% rename from Godeps/_workspace/src/github.com/minio/check/run_test.go rename to Godeps/_workspace/src/gopkg.in/check.v1/run_test.go index abd7c580a..f41fffc3f 100644 --- a/Godeps/_workspace/src/github.com/minio/check/run_test.go +++ b/Godeps/_workspace/src/gopkg.in/check.v1/run_test.go @@ -4,7 +4,7 @@ package check_test import ( "errors" - . "github.com/minio/check" + . "gopkg.in/check.v1" "os" "sync" ) @@ -400,7 +400,7 @@ func (s *RunS) TestStreamModeWithMiss(c *C) { // ----------------------------------------------------------------------- // Verify that that the keep work dir request indeed does so. -type WorkDirSuite struct{} +type WorkDirSuite struct {} func (s *WorkDirSuite) Test(c *C) { c.MkDir() @@ -411,7 +411,7 @@ func (s *RunS) TestKeepWorkDir(c *C) { runConf := RunConf{Output: &output, Verbose: true, KeepWorkDir: true} 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) c.Assert(err, IsNil) diff --git a/pkg/auth/auth_test.go b/pkg/auth/auth_test.go index 6ccbbc5f2..4020cb041 100644 --- a/pkg/auth/auth_test.go +++ b/pkg/auth/auth_test.go @@ -19,8 +19,8 @@ package auth_test import ( "testing" - . "github.com/minio/check" "github.com/minio/minio/pkg/auth" + . "gopkg.in/check.v1" ) func Test(t *testing.T) { TestingT(t) } diff --git a/pkg/cpu/cpu_test.go b/pkg/cpu/cpu_test.go index 3e3f67924..249807e4e 100644 --- a/pkg/cpu/cpu_test.go +++ b/pkg/cpu/cpu_test.go @@ -23,8 +23,8 @@ import ( "strings" "testing" - . "github.com/minio/check" "github.com/minio/minio/pkg/cpu" + . "gopkg.in/check.v1" ) func Test(t *testing.T) { TestingT(t) } diff --git a/pkg/crypto/md5/md5_test.go b/pkg/crypto/md5/md5_test.go index c39fdd6c6..d77a7c6d2 100644 --- a/pkg/crypto/md5/md5_test.go +++ b/pkg/crypto/md5/md5_test.go @@ -5,8 +5,8 @@ import ( "encoding/hex" "testing" - . "github.com/minio/check" "github.com/minio/minio/pkg/crypto/md5" + . "gopkg.in/check.v1" ) func Test(t *testing.T) { TestingT(t) } diff --git a/pkg/donut/bucket.go b/pkg/donut/bucket.go index 00e3247b4..83e7e1e93 100644 --- a/pkg/donut/bucket.go +++ b/pkg/donut/bucket.go @@ -19,7 +19,6 @@ package donut import ( "bytes" "fmt" - "hash" "io" "path/filepath" "sort" @@ -154,6 +153,13 @@ func (b bucket) ListObjects(prefix, marker, delimiter string, maxkeys int) (List if 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 { if strings.HasPrefix(objectName, strings.TrimSpace(prefix)) { if objectName > marker { @@ -171,7 +177,7 @@ func (b bucket) ListObjects(prefix, marker, delimiter string, maxkeys int) (List filteredObjects = HasNoDelimiter(objects, delimiter) prefixes = HasDelimiter(objects, delimiter) prefixes = SplitDelimiter(prefixes, delimiter) - prefixes = SortU(prefixes) + prefixes = SortUnique(prefixes) } var results []string var commonPrefixes []string @@ -264,8 +270,9 @@ func (b bucket) WriteObject(objectName string, objectData io.Reader, expectedMD5 CleanupWritersOnError(writers) return ObjectMetadata{}, iodine.New(err, nil) } + mwriter := io.MultiWriter(sumMD5, sum256, sum512) // 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 { CleanupWritersOnError(writers) return ObjectMetadata{}, iodine.New(err, nil) @@ -364,11 +371,11 @@ func (b bucket) writeObjectMetadata(objectName string, objMetadata ObjectMetadat // readObjectMetadata - read object metadata func (b bucket) readObjectMetadata(objectName string) (ObjectMetadata, error) { - objMetadata := ObjectMetadata{} if objectName == "" { return ObjectMetadata{}, iodine.New(InvalidArgument{}, nil) } var err error + objMetadata := ObjectMetadata{} objMetadataReaders, err := b.getObjectReaders(objectName, objectMetadataConfig) if 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 - -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") if 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) } - sumMD5.Write(chunk.Data) - sum256.Write(chunk.Data) - sum512.Write(chunk.Data) + writer.Write(chunk.Data) for blockIndex, block := range encodedBlocks { errCh := make(chan error, 1) go func(writer io.Writer, reader io.Reader) { diff --git a/pkg/donut/cache/data/data_test.go b/pkg/donut/cache/data/data_test.go index 31487d777..b7918f3db 100644 --- a/pkg/donut/cache/data/data_test.go +++ b/pkg/donut/cache/data/data_test.go @@ -19,7 +19,7 @@ package data import ( "testing" - . "github.com/minio/check" + . "gopkg.in/check.v1" ) func Test(t *testing.T) { TestingT(t) } diff --git a/pkg/donut/cache/metadata/metadata_test.go b/pkg/donut/cache/metadata/metadata_test.go index c12a9a447..ee126b689 100644 --- a/pkg/donut/cache/metadata/metadata_test.go +++ b/pkg/donut/cache/metadata/metadata_test.go @@ -19,7 +19,7 @@ package metadata import ( "testing" - . "github.com/minio/check" + . "gopkg.in/check.v1" ) func Test(t *testing.T) { TestingT(t) } diff --git a/pkg/donut/common.go b/pkg/donut/common.go index 96fadd4fb..eef8ebb20 100644 --- a/pkg/donut/common.go +++ b/pkg/donut/common.go @@ -168,8 +168,8 @@ func SplitDelimiter(objects []string, delim string) []string { return results } -// SortU sort a slice in lexical order, removing duplicate elements -func SortU(objects []string) []string { +// SortUnique sort a slice in lexical order, removing duplicate elements +func SortUnique(objects []string) []string { objectMap := make(map[string]string) for _, v := range objects { objectMap[v] = v diff --git a/pkg/donut/disk/disk_test.go b/pkg/donut/disk/disk_test.go index 93fc9e87f..8b82f137a 100644 --- a/pkg/donut/disk/disk_test.go +++ b/pkg/donut/disk/disk_test.go @@ -22,7 +22,7 @@ import ( "path/filepath" "testing" - . "github.com/minio/check" + . "gopkg.in/check.v1" ) func TestDisk(t *testing.T) { TestingT(t) } diff --git a/pkg/donut/donut-v1.go b/pkg/donut/donut-v1.go index 60da63526..b93a745c6 100644 --- a/pkg/donut/donut-v1.go +++ b/pkg/donut/donut-v1.go @@ -191,7 +191,7 @@ func (donut API) putObjectPart(bucket, object, expectedMD5Sum, uploadID string, if err != nil { 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) } if _, ok := bucketMeta.Buckets[bucket].BucketObjects[object]; ok { @@ -208,9 +208,9 @@ func (donut API) putObjectPart(bucket, object, expectedMD5Sum, uploadID string, ETag: objmetadata.MD5Sum, Size: objmetadata.Size, } - multipartSession := bucketMeta.Buckets[bucket].Multiparts[object+uploadID] + multipartSession := bucketMeta.Buckets[bucket].Multiparts[object] 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 { return PartMetadata{}, iodine.New(err, errParams) } @@ -297,7 +297,7 @@ func (donut API) newMultipartUpload(bucket, object, contentType string) (string, Parts: make(map[string]PartMetadata), TotalParts: 0, } - multiparts[object+uploadID] = multipartSession + multiparts[object] = multipartSession bucketMetadata.Multiparts = multiparts allbuckets.Buckets[bucket] = bucketMetadata @@ -326,12 +326,16 @@ func (donut API) listObjectParts(bucket, object string, resources ObjectResource if _, ok := donut.buckets[bucket]; !ok { return ObjectResourcesMetadata{}, iodine.New(BucketNotFound{Bucket: bucket}, errParams) } - bucketMetadata, err := donut.getDonutBucketMetadata() + allBuckets, err := donut.getDonutBucketMetadata() if err != nil { return ObjectResourcesMetadata{}, iodine.New(err, errParams) } - if _, ok := bucketMetadata.Buckets[bucket].Multiparts[object+resources.UploadID]; !ok { - return ObjectResourcesMetadata{}, iodine.New(InvalidUploadID{UploadID: resources.UploadID}, nil) + bucketMetadata := allBuckets.Buckets[bucket] + 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.Bucket = bucket @@ -344,7 +348,7 @@ func (donut API) listObjectParts(bucket, object string, resources ObjectResource default: 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 { sort.Sort(partNumber(parts)) objectResourcesMetadata.IsTruncated = true @@ -352,7 +356,7 @@ func (donut API) listObjectParts(bucket, object string, resources ObjectResource objectResourcesMetadata.NextPartNumberMarker = i 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 { 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 { return ObjectMetadata{}, iodine.New(BucketNotFound{Bucket: bucket}, errParams) } - bucketMetadata, err := donut.getDonutBucketMetadata() + allBuckets, err := donut.getDonutBucketMetadata() if err != nil { 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) } 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)) { 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 finalSize int64 - totalParts := strconv.Itoa(bucketMetadata.Buckets[bucket].Multiparts[object+uploadID].TotalParts) - for _, part := range bucketMetadata.Buckets[bucket].Multiparts[object+uploadID].Parts { + totalParts := strconv.Itoa(bucketMetadata.Multiparts[object].TotalParts) + for _, part := range bucketMetadata.Multiparts[object].Parts { partETagBytes, err := hex.DecodeString(part.ETag) if err != nil { return ObjectMetadata{}, iodine.New(err, errParams) @@ -426,7 +439,7 @@ func (donut API) completeMultipartUpload(bucket, object, uploadID string, data i objMetadata.Object = object objMetadata.Bucket = bucket 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 } @@ -446,7 +459,6 @@ func (donut API) listMultipartUploads(bucket string, resources BucketMultipartRe return BucketMultipartResourcesMetadata{}, iodine.New(err, errParams) } bucketMetadata := allbuckets.Buckets[bucket] - var uploads []*UploadMetadata for key, session := range bucketMetadata.Multiparts { if strings.HasPrefix(key, resources.Prefix) { @@ -510,7 +522,13 @@ func (donut API) abortMultipartUpload(bucket, object, uploadID string) error { return iodine.New(err, errParams) } 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 if err := donut.setDonutBucketMetadata(allbuckets); err != nil { diff --git a/pkg/donut/donut-v1_test.go b/pkg/donut/donut-v1_test.go index 80fe565e3..518c8786b 100644 --- a/pkg/donut/donut-v1_test.go +++ b/pkg/donut/donut-v1_test.go @@ -27,7 +27,7 @@ import ( "strconv" "testing" - . "github.com/minio/check" + . "gopkg.in/check.v1" ) func TestDonut(t *testing.T) { TestingT(t) } diff --git a/pkg/donut/donut-v2.go b/pkg/donut/donut-v2.go index 7f65d3ab2..c0a77afaf 100644 --- a/pkg/donut/donut-v2.go +++ b/pkg/donut/donut-v2.go @@ -579,7 +579,7 @@ func (donut API) ListObjects(bucket string, resources BucketResourcesMetadata, s filteredKeys = HasNoDelimiter(keys, resources.Delimiter) prefixes = HasDelimiter(keys, resources.Delimiter) prefixes = SplitDelimiter(prefixes, resources.Delimiter) - prefixes = SortU(prefixes) + prefixes = SortUnique(prefixes) } for _, commonPrefix := range prefixes { resources.CommonPrefixes = append(resources.CommonPrefixes, resources.Prefix+commonPrefix) diff --git a/pkg/donut/donut-v2_test.go b/pkg/donut/donut-v2_test.go index 5c835de0d..825fb9125 100644 --- a/pkg/donut/donut-v2_test.go +++ b/pkg/donut/donut-v2_test.go @@ -26,7 +26,7 @@ import ( "path/filepath" "testing" - . "github.com/minio/check" + . "gopkg.in/check.v1" ) func TestCache(t *testing.T) { TestingT(t) } diff --git a/pkg/donut/split/split_test.go b/pkg/donut/split/split_test.go index 94413a988..d86f840af 100644 --- a/pkg/donut/split/split_test.go +++ b/pkg/donut/split/split_test.go @@ -24,8 +24,8 @@ import ( "strconv" "testing" - . "github.com/minio/check" "github.com/minio/minio/pkg/donut/split" + . "gopkg.in/check.v1" ) type MySuite struct{} diff --git a/pkg/erasure/cauchy_test.go b/pkg/erasure/cauchy_test.go index 0c783276f..37f28c74c 100644 --- a/pkg/erasure/cauchy_test.go +++ b/pkg/erasure/cauchy_test.go @@ -20,7 +20,7 @@ import ( "bytes" "testing" - . "github.com/minio/check" + . "gopkg.in/check.v1" ) type MySuite struct{} diff --git a/pkg/erasure/vandermonde_test.go b/pkg/erasure/vandermonde_test.go index c126bdfd9..490830557 100644 --- a/pkg/erasure/vandermonde_test.go +++ b/pkg/erasure/vandermonde_test.go @@ -19,7 +19,7 @@ package erasure import ( "bytes" - . "github.com/minio/check" + . "gopkg.in/check.v1" ) func corruptChunks(chunks [][]byte, errorIndex []int) [][]byte { diff --git a/pkg/quick/quick_test.go b/pkg/quick/quick_test.go index 3140626f5..84af748d8 100644 --- a/pkg/quick/quick_test.go +++ b/pkg/quick/quick_test.go @@ -22,7 +22,7 @@ import ( "os" "testing" - . "github.com/minio/check" + . "gopkg.in/check.v1" ) func Test(t *testing.T) { TestingT(t) } diff --git a/pkg/server/api_donut_cache_test.go b/pkg/server/api_donut_cache_test.go index a7ec5f4f9..190ddd7ea 100644 --- a/pkg/server/api_donut_cache_test.go +++ b/pkg/server/api_donut_cache_test.go @@ -28,9 +28,9 @@ import ( "net/http" "net/http/httptest" - . "github.com/minio/check" "github.com/minio/minio/pkg/donut" "github.com/minio/minio/pkg/server/api" + . "gopkg.in/check.v1" ) func TestAPIDonutCache(t *testing.T) { TestingT(t) } diff --git a/pkg/server/api_donut_test.go b/pkg/server/api_donut_test.go index becf287c9..bdb141258 100644 --- a/pkg/server/api_donut_test.go +++ b/pkg/server/api_donut_test.go @@ -29,9 +29,9 @@ import ( "net/http" "net/http/httptest" - . "github.com/minio/check" "github.com/minio/minio/pkg/donut" "github.com/minio/minio/pkg/server/api" + . "gopkg.in/check.v1" ) func TestAPIDonut(t *testing.T) { TestingT(t) } diff --git a/pkg/server/api_signature_v4_test.go b/pkg/server/api_signature_v4_test.go index bf25530dc..1ebb54f19 100644 --- a/pkg/server/api_signature_v4_test.go +++ b/pkg/server/api_signature_v4_test.go @@ -29,10 +29,10 @@ import ( "net/http" "net/http/httptest" - . "github.com/minio/check" "github.com/minio/minio/pkg/auth" "github.com/minio/minio/pkg/donut" "github.com/minio/minio/pkg/server/api" + . "gopkg.in/check.v1" ) func TestAPISignatureV4(t *testing.T) { TestingT(t) } diff --git a/pkg/server/minhttp/net_test.go b/pkg/server/minhttp/net_test.go index de32afd81..9abed21c7 100644 --- a/pkg/server/minhttp/net_test.go +++ b/pkg/server/minhttp/net_test.go @@ -21,8 +21,8 @@ import ( "regexp" "testing" - . "github.com/minio/check" "github.com/minio/minio/pkg/iodine" + . "gopkg.in/check.v1" ) func Test(t *testing.T) { TestingT(t) } diff --git a/pkg/server/rpc_test.go b/pkg/server/rpc_test.go index a7f6dd583..0dd8dc0e9 100644 --- a/pkg/server/rpc_test.go +++ b/pkg/server/rpc_test.go @@ -22,9 +22,9 @@ import ( "testing" jsonrpc "github.com/gorilla/rpc/v2/json" - . "github.com/minio/check" "github.com/minio/minio/pkg/controller" "github.com/minio/minio/pkg/server/rpc" + . "gopkg.in/check.v1" ) func TestRPC(t *testing.T) { TestingT(t) } diff --git a/pkg/utils/atomic/atomic_test.go b/pkg/utils/atomic/atomic_test.go index 31871b75c..69f045fed 100644 --- a/pkg/utils/atomic/atomic_test.go +++ b/pkg/utils/atomic/atomic_test.go @@ -22,7 +22,7 @@ import ( "path/filepath" "testing" - . "github.com/minio/check" + . "gopkg.in/check.v1" ) func Test(t *testing.T) { TestingT(t) }