diff options
Diffstat (limited to 'weed/shell')
| -rw-r--r-- | weed/shell/command_fs_meta_cat.go | 20 | ||||
| -rw-r--r-- | weed/shell/command_remote_configure.go | 10 | ||||
| -rw-r--r-- | weed/shell/command_remote_mount.go | 13 |
3 files changed, 4 insertions, 39 deletions
diff --git a/weed/shell/command_fs_meta_cat.go b/weed/shell/command_fs_meta_cat.go index 4f3b3551e..3ae106415 100644 --- a/weed/shell/command_fs_meta_cat.go +++ b/weed/shell/command_fs_meta_cat.go @@ -2,8 +2,7 @@ package shell import ( "fmt" - "golang.org/x/exp/slices" - "google.golang.org/protobuf/jsonpb" + "github.com/seaweedfs/seaweedfs/weed/filer" "google.golang.org/protobuf/proto" "io" @@ -50,22 +49,7 @@ func (c *commandFsMetaCat) Do(args []string, commandEnv *CommandEnv, writer io.W return err } - m := jsonpb.Marshaler{ - EmitDefaults: true, - Indent: " ", - } - slices.SortFunc(respLookupEntry.Entry.Chunks, func(a, b *filer_pb.FileChunk) bool { - if a.Offset == b.Offset { - return a.Mtime < b.Mtime - } - return a.Offset < b.Offset - }) - text, marshalErr := m.MarshalToString(respLookupEntry.Entry) - if marshalErr != nil { - return fmt.Errorf("marshal meta: %v", marshalErr) - } - - fmt.Fprintf(writer, "%s\n", text) + filer.ProtoToText(writer, respLookupEntry.Entry) bytes, _ := proto.Marshal(respLookupEntry.Entry) gzippedBytes, _ := util.GzipData(bytes) diff --git a/weed/shell/command_remote_configure.go b/weed/shell/command_remote_configure.go index 306858271..4491dc456 100644 --- a/weed/shell/command_remote_configure.go +++ b/weed/shell/command_remote_configure.go @@ -9,7 +9,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" - "google.golang.org/protobuf/jsonpb" "google.golang.org/protobuf/proto" "io" "regexp" @@ -159,15 +158,8 @@ func (c *commandRemoteConfigure) listExistingRemoteStorages(commandEnv *CommandE conf.TencentSecretKey = strings.Repeat("*", len(conf.TencentSecretKey)) conf.WasabiSecretKey = strings.Repeat("*", len(conf.WasabiSecretKey)) - m := jsonpb.Marshaler{ - EmitDefaults: false, - Indent: " ", - } - - err := m.Marshal(writer, conf) - fmt.Fprintln(writer) + return filer.ProtoToText(writer, conf) - return err }) } diff --git a/weed/shell/command_remote_mount.go b/weed/shell/command_remote_mount.go index ef837a821..0f74729f1 100644 --- a/weed/shell/command_remote_mount.go +++ b/weed/shell/command_remote_mount.go @@ -9,7 +9,6 @@ import ( "github.com/seaweedfs/seaweedfs/weed/pb/remote_pb" "github.com/seaweedfs/seaweedfs/weed/remote_storage" "github.com/seaweedfs/seaweedfs/weed/util" - "google.golang.org/protobuf/jsonpb" "google.golang.org/protobuf/proto" "io" "os" @@ -101,17 +100,7 @@ func listExistingRemoteStorageMounts(commandEnv *CommandEnv, writer io.Writer) ( } func jsonPrintln(writer io.Writer, message proto.Message) error { - if message == nil { - return nil - } - m := jsonpb.Marshaler{ - EmitDefaults: false, - Indent: " ", - } - - err := m.Marshal(writer, message) - fmt.Fprintln(writer) - return err + return filer.ProtoToText(writer, message) } func syncMetadata(commandEnv *CommandEnv, writer io.Writer, dir string, nonEmpty bool, remoteConf *remote_pb.RemoteConf, remote *remote_pb.RemoteStorageLocation) error { |
