aboutsummaryrefslogtreecommitdiff
path: root/weed/command/upload.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-01-21 00:47:27 -0800
committerChris Lu <chris.lu@gmail.com>2021-01-21 00:47:27 -0800
commita9e6db1a8e964f10571a5e11c197fd2da141c6f7 (patch)
tree0a22db3d6c68178d8e913c1bffd550ae4127a7e1 /weed/command/upload.go
parentf0455dee683e831487c345a575b7894c0e2bf61a (diff)
parent84f05787f8eecfcb61e49882346ad5855b6bb784 (diff)
downloadseaweedfs-origin/ftp.tar.xz
seaweedfs-origin/ftp.zip
Merge branch 'master' into ftporigin/ftp
Diffstat (limited to 'weed/command/upload.go')
-rw-r--r--weed/command/upload.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/weed/command/upload.go b/weed/command/upload.go
index 45b15535b..7115da587 100644
--- a/weed/command/upload.go
+++ b/weed/command/upload.go
@@ -1,8 +1,12 @@
package command
import (
+ "context"
"encoding/json"
"fmt"
+ "github.com/chrislusf/seaweedfs/weed/pb"
+ "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
+ "google.golang.org/grpc"
"os"
"path/filepath"
@@ -65,6 +69,15 @@ func runUpload(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
+ defaultCollection, err := readMasterConfiguration(grpcDialOption, *upload.master)
+ if err != nil {
+ fmt.Printf("upload: %v", err)
+ return false
+ }
+ if *upload.replication == "" {
+ *upload.replication = defaultCollection
+ }
+
if len(args) == 0 {
if *upload.dir == "" {
return false
@@ -104,3 +117,15 @@ func runUpload(cmd *Command, args []string) bool {
}
return true
}
+
+func readMasterConfiguration(grpcDialOption grpc.DialOption, masterAddress string) (replication string, err error) {
+ err = pb.WithMasterClient(masterAddress, grpcDialOption, func(client master_pb.SeaweedClient) error {
+ resp, err := client.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
+ if err != nil {
+ return fmt.Errorf("get master %s configuration: %v", masterAddress, err)
+ }
+ replication = resp.DefaultReplication
+ return nil
+ })
+ return
+}