aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2021-06-07 15:47:08 -0700
committerGitHub <noreply@github.com>2021-06-07 15:47:08 -0700
commit492a91e0b09d0f4f2d673fb73ecc0568eaee4785 (patch)
tree11018c5f95dab620a6f1c0103f4e079dcac87d22
parent76f24af79add7c282de3ce420c136bfe29cf7fa5 (diff)
parent0e3adde47fec0ed4914d222050e7da6d695d8c84 (diff)
downloadseaweedfs-492a91e0b09d0f4f2d673fb73ecc0568eaee4785.tar.xz
seaweedfs-492a91e0b09d0f4f2d673fb73ecc0568eaee4785.zip
Merge pull request #2115 from nagy/exitcode
Return correct exitcode when `wheed upload` fails
-rw-r--r--weed/command/upload.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/weed/command/upload.go b/weed/command/upload.go
index 0f9361b40..a102796b4 100644
--- a/weed/command/upload.go
+++ b/weed/command/upload.go
@@ -84,7 +84,7 @@ func runUpload(cmd *Command, args []string) bool {
if *upload.dir == "" {
return false
}
- filepath.Walk(util.ResolvePath(*upload.dir), func(path string, info os.FileInfo, err error) error {
+ err = filepath.Walk(util.ResolvePath(*upload.dir), func(path string, info os.FileInfo, err error) error {
if err == nil {
if !info.IsDir() {
if *upload.include != "" {
@@ -108,12 +108,21 @@ func runUpload(cmd *Command, args []string) bool {
}
return err
})
+ if err != nil {
+ fmt.Println(err.Error())
+ return false;
+ }
} else {
parts, e := operation.NewFileParts(args)
if e != nil {
fmt.Println(e.Error())
+ return false
+ }
+ results, err := operation.SubmitFiles(func() string { return *upload.master }, grpcDialOption, parts, *upload.replication, *upload.collection, *upload.dataCenter, *upload.ttl, *upload.diskType, *upload.maxMB, *upload.usePublicUrl)
+ if err != nil {
+ fmt.Println(err.Error())
+ return false
}
- results, _ := operation.SubmitFiles(func() string { return *upload.master }, grpcDialOption, parts, *upload.replication, *upload.collection, *upload.dataCenter, *upload.ttl, *upload.diskType, *upload.maxMB, *upload.usePublicUrl)
bytes, _ := json.Marshal(results)
fmt.Println(string(bytes))
}