Browse Source

shell: fs.meta.load add quieter mode

fix https://github.com/seaweedfs/seaweedfs/issues/3414
pull/3415/head
chrislu 2 years ago
parent
commit
d3d52b1818
  1. 15
      weed/shell/command_fs_meta_load.go

15
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
}
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++

Loading…
Cancel
Save