Adding sys. as reserved in erasureWriter

master
Frederick F. Kautz IV 10 years ago
parent 920c734b2f
commit d57e9d6c18
  1. 18
      pkg/storage/donut/donutdriver_test.go
  2. 8
      pkg/storage/donut/erasure.go

@ -204,3 +204,21 @@ func (s *MySuite) TestMultipleNewObjects(c *C) {
c.Assert(err, IsNil)
c.Assert(listObjects, DeepEquals, []string{"obj1", "obj2"})
}
func (s *MySuite) TestSysPrefixShouldFail(c *C) {
root, err := ioutil.TempDir(os.TempDir(), "donut-")
c.Assert(err, IsNil)
defer os.RemoveAll(root)
donut := NewDonutDriver(root)
c.Assert(donut.CreateBucket("foo"), IsNil)
writer, err := donut.GetObjectWriter("foo", "obj1")
c.Assert(err, IsNil)
writer.Write([]byte("one"))
metadata := make(map[string]string)
metadata["foo"] = "bar"
metadata["sys.hello"] = "world"
err = writer.SetMetadata(metadata)
c.Assert(err, Not(IsNil))
writer.Close()
}

@ -11,6 +11,7 @@ import (
"errors"
"github.com/minio-io/minio/pkg/encoding/erasure"
"github.com/minio-io/minio/pkg/utils/split"
"strings"
)
func erasureReader(readers []io.ReadCloser, donutMetadata map[string]string, writer *io.PipeWriter) {
@ -108,8 +109,8 @@ func erasureGoroutine(r *io.PipeReader, eWriter erasureWriter, isClosed chan<- b
metadata["erasureK"] = "8"
metadata["erasureM"] = "8"
metadata["erasureTechnique"] = "Cauchy"
metadata["totalLength"] = strconv.Itoa(totalLength)
metadata["md5"] = hex.EncodeToString(dataMd5sum)
metadata["totalLength"] = strconv.Itoa(totalLength)
for _, nodeWriter := range eWriter.writers {
if nodeWriter != nil {
nodeWriter.SetMetadata(eWriter.metadata)
@ -141,6 +142,11 @@ func (d erasureWriter) CloseWithError(err error) error {
}
func (d erasureWriter) SetMetadata(metadata map[string]string) error {
for k, _ := range metadata {
if strings.HasPrefix(k, "sys.") {
return errors.New("Invalid key '" + k + "', cannot start with sys.'")
}
}
for k := range d.metadata {
delete(d.metadata, k)
}

Loading…
Cancel
Save