aboutsummaryrefslogtreecommitdiff
path: root/weed/filer
diff options
context:
space:
mode:
Diffstat (limited to 'weed/filer')
-rw-r--r--weed/filer/entry_codec.go2
-rw-r--r--weed/filer/filer_conf.go12
-rw-r--r--weed/filer/s3iam_conf.go23
3 files changed, 20 insertions, 17 deletions
diff --git a/weed/filer/entry_codec.go b/weed/filer/entry_codec.go
index 786ecea49..ce9c0484b 100644
--- a/weed/filer/entry_codec.go
+++ b/weed/filer/entry_codec.go
@@ -21,7 +21,7 @@ func (entry *Entry) DecodeAttributesAndChunks(blob []byte) error {
message := &filer_pb.Entry{}
- if err := proto.UnmarshalMerge(blob, message); err != nil {
+ if err := proto.Unmarshal(blob, message); err != nil {
return fmt.Errorf("decoding value blob for %s: %v", entry.FullPath, err)
}
diff --git a/weed/filer/filer_conf.go b/weed/filer/filer_conf.go
index 59abaa5ab..30161cfaf 100644
--- a/weed/filer/filer_conf.go
+++ b/weed/filer/filer_conf.go
@@ -13,7 +13,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/util"
"github.com/viant/ptrie"
- "google.golang.org/protobuf/jsonpb"
+ jsonpb "google.golang.org/protobuf/encoding/protojson"
)
const (
@@ -93,7 +93,7 @@ func (fc *FilerConf) loadFromChunks(filer *Filer, content []byte, chunks []*file
func (fc *FilerConf) LoadFromBytes(data []byte) (err error) {
conf := &filer_pb.FilerConf{}
- if err := jsonpb.Unmarshal(bytes.NewReader(data), conf); err != nil {
+ if err := jsonpb.Unmarshal(data, conf); err != nil {
return err
}
@@ -181,11 +181,5 @@ func (fc *FilerConf) ToProto() *filer_pb.FilerConf {
}
func (fc *FilerConf) ToText(writer io.Writer) error {
-
- m := jsonpb.Marshaler{
- EmitDefaults: false,
- Indent: " ",
- }
-
- return m.Marshal(writer, fc.ToProto())
+ return ProtoToText(writer, fc.ToProto())
}
diff --git a/weed/filer/s3iam_conf.go b/weed/filer/s3iam_conf.go
index 6240058a4..24ed46be5 100644
--- a/weed/filer/s3iam_conf.go
+++ b/weed/filer/s3iam_conf.go
@@ -1,17 +1,16 @@
package filer
import (
- "bytes"
"fmt"
"io"
"github.com/seaweedfs/seaweedfs/weed/pb/iam_pb"
- "google.golang.org/protobuf/jsonpb"
+ jsonpb "google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
)
func ParseS3ConfigurationFromBytes[T proto.Message](content []byte, config T) error {
- if err := jsonpb.Unmarshal(bytes.NewBuffer(content), config); err != nil {
+ if err := jsonpb.Unmarshal(content, config); err != nil {
return err
}
return nil
@@ -19,12 +18,22 @@ func ParseS3ConfigurationFromBytes[T proto.Message](content []byte, config T) er
func ProtoToText(writer io.Writer, config proto.Message) error {
- m := jsonpb.Marshaler{
- EmitDefaults: false,
- Indent: " ",
+ m := jsonpb.MarshalOptions{
+ EmitUnpopulated: true,
+ Indent: " ",
}
- return m.Marshal(writer, config)
+ text, marshalErr := m.Marshal(config)
+ if marshalErr != nil {
+ return fmt.Errorf("marshal proto message: %v", marshalErr)
+ }
+
+ _, writeErr := writer.Write(text)
+ if writeErr != nil {
+ return fmt.Errorf("fail to write proto message: %v", writeErr)
+ }
+
+ return writeErr
}
// CheckDuplicateAccessKey returns an error message when s3cfg has duplicate access keys