diff options
| author | Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> | 2022-09-27 21:58:46 +0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-27 09:58:46 -0700 |
| commit | faa6167b6b706cbd38c78cf4c1f3b91ce60598f1 (patch) | |
| tree | fb647640ad988ff39974f1ffecc7397cdc209945 | |
| parent | b6d7556dda6ee49dc956bf06da716470144d409b (diff) | |
| download | seaweedfs-faa6167b6b706cbd38c78cf4c1f3b91ce60598f1.tar.xz seaweedfs-faa6167b6b706cbd38c78cf4c1f3b91ce60598f1.zip | |
fs.meta.load load any dirs with prefix "important" (#3747)
* fs.meta.load load any dirs with prefix "important"
* replace dirPattern to dirPrefix
* help dirPrefix
| -rw-r--r-- | weed/shell/command_fs_meta_load.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/weed/shell/command_fs_meta_load.go b/weed/shell/command_fs_meta_load.go index 3bd10c1e9..0cbdddb49 100644 --- a/weed/shell/command_fs_meta_load.go +++ b/weed/shell/command_fs_meta_load.go @@ -19,6 +19,7 @@ func init() { } type commandFsMetaLoad struct { + dirPrefix *string } func (c *commandFsMetaLoad) Name() string { @@ -30,6 +31,7 @@ func (c *commandFsMetaLoad) Help() string { fs.meta.load <filer_host>-<port>-<time>.meta fs.meta.load -v=false <filer_host>-<port>-<time>.meta // skip printing out the verbose output + fs.meta.load -dirPrefix=/buckets/important* <filer_host>.meta // load any dirs with prefix "important" ` } @@ -44,6 +46,7 @@ func (c *commandFsMetaLoad) Do(args []string, commandEnv *CommandEnv, writer io. fileName := args[len(args)-1] metaLoadCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) + c.dirPrefix = metaLoadCommand.String("dirPrefix", "", "load entries only with directories matching prefix") verbose := metaLoadCommand.Bool("v", true, "verbose mode") if err = metaLoadCommand.Parse(args[0 : len(args)-1]); err != nil { return nil @@ -83,11 +86,22 @@ func (c *commandFsMetaLoad) Do(args []string, commandEnv *CommandEnv, writer io. return err } + // check collection name pattern + entryFullName := string(util.FullPath(fullEntry.Dir).Child(fullEntry.Entry.Name)) + if *c.dirPrefix != "" { + if !strings.HasPrefix(fullEntry.Dir, *c.dirPrefix) { + if *verbose { + fmt.Fprintf(writer, "not match dir prefix %s\n", entryFullName) + } + continue + } + } + 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)) + fmt.Fprintf(writer, "load %s\n", entryFullName) } fullEntry.Entry.Name = strings.ReplaceAll(fullEntry.Entry.Name, "/", "x") |
