aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-08-07 01:42:15 -0700
committerchrislu <chris.lu@gmail.com>2022-08-07 01:42:15 -0700
commitd3d52b1818cac8aa1a2cf0dd2bcd941dc707b8a0 (patch)
treefe498adbbcddc67927db00fba4e4e8ca0ce1f74c
parent358ccb5e0eb2fd0d5f7f1bd6259dc5950df76526 (diff)
downloadseaweedfs-d3d52b1818cac8aa1a2cf0dd2bcd941dc707b8a0.tar.xz
seaweedfs-d3d52b1818cac8aa1a2cf0dd2bcd941dc707b8a0.zip
shell: fs.meta.load add quieter mode
fix https://github.com/seaweedfs/seaweedfs/issues/3414
-rw-r--r--weed/shell/command_fs_meta_load.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/weed/shell/command_fs_meta_load.go b/weed/shell/command_fs_meta_load.go
index b5a5a381a..ced5f5b88 100644
--- a/weed/shell/command_fs_meta_load.go
+++ b/weed/shell/command_fs_meta_load.go
@@ -1,10 +1,12 @@
package shell
import (
+ "flag"
"fmt"
"io"
"os"
"strings"
+ "time"
"github.com/golang/protobuf/proto"
@@ -27,6 +29,7 @@ func (c *commandFsMetaLoad) Help() string {
return `load saved filer meta data to restore the directory and file structure
fs.meta.load <filer_host>-<port>-<time>.meta
+ fs.meta.load -v=false <filer_host>-<port>-<time>.meta // skip printing out the verbose output
`
}
@@ -40,6 +43,12 @@ func (c *commandFsMetaLoad) Do(args []string, commandEnv *CommandEnv, writer io.
fileName := args[len(args)-1]
+ metaLoadCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
+ verbose := metaLoadCommand.Bool("v", true, "verbose mode")
+ if err = metaLoadCommand.Parse(args[0 : len(args)-1]); err != nil {
+ return nil
+ }
+
dst, err := os.OpenFile(fileName, os.O_RDONLY, 0644)
if err != nil {
return nil
@@ -47,6 +56,7 @@ func (c *commandFsMetaLoad) Do(args []string, commandEnv *CommandEnv, writer io.
defer dst.Close()
var dirCount, fileCount uint64
+ lastLogTime := time.Now()
err = commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
@@ -81,7 +91,12 @@ func (c *commandFsMetaLoad) Do(args []string, commandEnv *CommandEnv, writer io.
return err
}
- fmt.Fprintf(writer, "load %s\n", util.FullPath(fullEntry.Dir).Child(fullEntry.Entry.Name))
+ if *verbose || lastLogTime.Add(time.Second).Before(time.Now()) {
+ if !*verbose {
+ lastLogTime = time.Now()
+ }
+ fmt.Fprintf(writer, "load %s\n", util.FullPath(fullEntry.Dir).Child(fullEntry.Entry.Name))
+ }
if fullEntry.Entry.IsDirectory {
dirCount++