SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
filer.copy: automatically use the right bucket
Chris Lu147d4d23b641
diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.goindex 88148acc57..610a3e5102 100644--- a/weed/command/filer_copy.go+++ b/weed/command/filer_copy.go@@ -111,11 +111,23 @@ func runCopy(cmd *Command, args []string) bool {filerGrpcAddress := fmt.Sprintf("%s:%d", filerUrl.Hostname(), filerGrpcPort)copy.grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")- masters, collection, replication, maxMB, cipher, err := readFilerConfiguration(copy.grpcDialOption, filerGrpcAddress)+ masters, collection, replication, dirBuckets, maxMB, cipher, err := readFilerConfiguration(copy.grpcDialOption, filerGrpcAddress)if err != nil {fmt.Printf("read from filer %s: %v\n", filerGrpcAddress, err)return false}+ if strings.HasPrefix(urlPath, dirBuckets) {+ restPath := urlPath[len(dirBuckets)+1:]+ if strings.Index(restPath, "/") > 0 {+ expectedBucket := restPath[:strings.Index(restPath, "/")]+ if *copy.collection == "" {+ *copy.collection = expectedBucket+ } else {+ fmt.Printf("destination %s uses collection \"%s\": unexpected collection \"%v\"\n", urlPath, expectedBucket, *copy.collection)+ return true+ }+ }+ }if *copy.collection == "" {*copy.collection = collection}@@ -170,13 +182,14 @@ func runCopy(cmd *Command, args []string) bool {return true}-func readFilerConfiguration(grpcDialOption grpc.DialOption, filerGrpcAddress string) (masters []string, collection, replication string, maxMB uint32, cipher bool, err error) {+func readFilerConfiguration(grpcDialOption grpc.DialOption, filerGrpcAddress string) (masters []string, collection, replication string, dirBuckets string, maxMB uint32, cipher bool, err error) {err = pb.WithGrpcFilerClient(filerGrpcAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})if err != nil {return fmt.Errorf("get filer %s configuration: %v", filerGrpcAddress, err)}masters, collection, replication, maxMB = resp.Masters, resp.Collection, resp.Replication, resp.MaxMb+ dirBuckets = resp.DirBucketscipher = resp.Cipherreturn nil})