From d9c25ccbb0b0e9ddc3189a097177099a35a09052 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 13 Jul 2013 23:17:41 -0700 Subject: [PATCH] upload files recursively matching a pattern --- go/weed/upload.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/go/weed/upload.go b/go/weed/upload.go index 2e3a3f4b1..9d9a02527 100644 --- a/go/weed/upload.go +++ b/go/weed/upload.go @@ -16,6 +16,7 @@ import ( var ( uploadReplication *string uploadDir *string + include *string ) func init() { @@ -23,6 +24,7 @@ func init() { cmdUpload.IsDebug = cmdUpload.Flag.Bool("debug", false, "verbose debug information") server = cmdUpload.Flag.String("server", "localhost:9333", "weedfs master location") uploadDir = cmdUpload.Flag.String("dir", "", "Upload the whole folder recursively if specified.") + include = cmdUpload.Flag.String("include", "", "pattens of files to upload, e.g., *.pdf, *.html, ab?d.txt, works together with -dir") uploadReplication = cmdUpload.Flag.String("replication", "000", "replication type(000,001,010,100,110,200)") } @@ -127,6 +129,11 @@ func runUpload(cmd *Command, args []string) bool { filepath.Walk(*uploadDir, func(path string, info os.FileInfo, err error) error { if err == nil { if !info.IsDir() { + if *include != "" { + if ok, _ := filepath.Match(*include, filepath.Base(path)); !ok { + return nil + } + } results, e := submit([]string{path}) bytes, _ := json.Marshal(results) fmt.Println(string(bytes))