aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weed/filer/filer_conf.go24
-rw-r--r--weed/shell/command_fs_configure.go1
2 files changed, 20 insertions, 5 deletions
diff --git a/weed/filer/filer_conf.go b/weed/filer/filer_conf.go
index 4f317371b..182449d49 100644
--- a/weed/filer/filer_conf.go
+++ b/weed/filer/filer_conf.go
@@ -1,12 +1,14 @@
package filer
import (
+ "bytes"
"context"
"io"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util"
+ "github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"github.com/viant/ptrie"
)
@@ -53,10 +55,16 @@ func (fc *FilerConf) loadFromChunks(filer *Filer, chunks []*filer_pb.FileChunk)
func (fc *FilerConf) LoadFromBytes(data []byte) (err error) {
conf := &filer_pb.FilerConf{}
- err = proto.UnmarshalText(string(data), conf)
- if err != nil {
- glog.Errorf("unable to parse filer conf: %v", err)
- // this is not recoverable
+
+ if err := jsonpb.Unmarshal(bytes.NewReader(data), conf); err != nil {
+
+ err = proto.UnmarshalText(string(data), conf)
+ if err != nil {
+ glog.Errorf("unable to parse filer conf: %v", err)
+ // this is not recoverable
+ return nil
+ }
+
return nil
}
@@ -121,5 +129,11 @@ func (fc *FilerConf) ToProto() *filer_pb.FilerConf {
}
func (fc *FilerConf) ToText(writer io.Writer) error {
- return proto.MarshalText(writer, fc.ToProto())
+
+ m := jsonpb.Marshaler{
+ EmitDefaults: false,
+ Indent: " ",
+ }
+
+ return m.Marshal(writer, fc.ToProto())
}
diff --git a/weed/shell/command_fs_configure.go b/weed/shell/command_fs_configure.go
index 9f6b14439..d4d70048d 100644
--- a/weed/shell/command_fs_configure.go
+++ b/weed/shell/command_fs_configure.go
@@ -99,6 +99,7 @@ func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io
fc.ToText(&buf)
fmt.Fprintf(writer, string(buf.Bytes()))
+ fmt.Fprintln(writer)
if *apply {